I’ve never done it but you could probably create a custom transform 22. Perhaps searching on google for pytorch lambda transform or whatever will help you find some working code of it
Edit: Did just that
def foo(x):
    return x / 255.0

transforms.Lambda(lambda x: foo(x))