I added this method to my dataset class, which take the user-supplied transforms as an additional parameter:
    def _transform(self, image, mask, transform):
        """
        Apply transforms to both the image and the mask.

        :param transform: A transform object.
        :return: transformed image and mask
        """

        image = transform(image)
        mask  = transform(mask)

        return image, mask

I call it in my getitem()
    def __getitem__(self, index):

        <snip>

        """
        Sample of our dataset will be dict {'image': image, 'mask': mask}.
        This dataset will take an optional argument transform so that any
        required processing can be applied on the sample.

        We will convert the scale and convert the sample to uint8 so that
        it can be viewed as a normal file. This will be useful for offline
        batch processing to generate a cached dataset.
        """

        image = (image * 255).astype(np.uint8)
        mask  = (mask  * 255).astype(np.uint8)

        """
        Apply user-specified transforms to image and mask.
        """
        if self.transform:
            image, mask = self._transform(image, mask, self.transform)

        """
        Sample of our dataset will be dict {'image': image, 'mask': mask}.
        This dataset will take an optional argument transform so that any
        required processing can be applied on the sample.
        """
        sample = {'image': image,
                  'mask' : mask}

        return sample


and when I try to use it, I get the following error:
TypeError: Traceback (most recent call last):
  File "/tool/python/conda/env/gis36/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 57, in _worker_loop
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/tool/python/conda/env/gis36/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 57, in <listcomp>
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/project/geospatial/application/cs230-sifd/source/step/loader/sifd/dataset.py", line 388, in __getitem__
    image, mask = self._transform(image, mask, self.transform)
  File "/project/geospatial/application/cs230-sifd/source/step/loader/sifd/dataset.py", line 189, in _transform
    image = transform(image)
  File "/tool/python/conda/env/gis36/lib/python3.6/site-packages/torchvision-0.2.1-py3.6.egg/torchvision/transforms/transforms.py", line 49, in __call__
    img = t(img)
  File "/tool/python/conda/env/gis36/lib/python3.6/site-packages/torchvision-0.2.1-py3.6.egg/torchvision/transforms/transforms.py", line 421, in __call__
    i, j, h, w = self.get_params(img, self.size)
  File "/tool/python/conda/env/gis36/lib/python3.6/site-packages/torchvision-0.2.1-py3.6.egg/torchvision/transforms/transforms.py", line 394, in get_params
    w, h = img.size
TypeError: 'int' object is not iterable