Oh, I see what you mean. torchvision transforms are just nn.Modules. If you look at the implementations of these transforms like Resize. So you only need to define the forward pass. In your case, the input to the transform is the batch itself and you can implement your transform just like any other nn.Module.