Inside your Dataset you are assigning this functions to self.transform2.
This will basically assign the reference to this function as a class attribute.
In __getitem__ you are then calling self.transform2 with the necessary arguments.