T.Compose | TypeError: __call__() takes 2 positional arguments but 3 were given

I think the error is raised by Compose, which accepts only a single argument as seen here.

Reproduction of your error:

trans = transforms.Compose([transform_ToNumpy()])
a = TF.to_pil_image(torch.randn(3, 24, 24))
b = TF.to_pil_image(torch.randn(3, 24, 24))
x, y = trans(a, b)

A workaround would be to write a custom Compose class, which accepts and forwards two arguments:

class MyCompose(object):
    def __init__(self, transforms):
        self.transforms = transforms

    def __call__(self, img, tar):
        for t in self.transforms:
            img, tar = t(img, tar)
        return img, tar


trans = MyCompose([transform_ToNumpy()])
a = TF.to_pil_image(torch.randn(3, 24, 24))
b = TF.to_pil_image(torch.randn(3, 24, 24))
x, y = trans(a, b)