class MyNormalize:
    def __call__(self, img):
        if type(img) == np.ndarray:
            mean, std = np.mean(img), np.std(img)
        elif type(img) == torch.Tensor:
            mean, std = torch.mean(img), torch.std(img)
        img = img - mean
        img = img / std
        return img

This is the transform I created for myself. This custom transform can still work on GPUs. So I donnot think the first reason is important.