Questions on Customed ItemBase in Official CycleGAN Tutorial

I am trying to understand the code in CycleGAN notebook and I have a few questions related to the customed ItemBase, ItemList defined in the notebook (see Code Snippet below for reference):

  1. In TargetTupleList.reconstrcut, why the input tensor is transformed (i.e. t/2 + 0.5) before feeding into ImageTuple, while in ImageTuple.__init__, is transformed back to original t (i.e. [-1+2*,-1+2*])? It seems strange to me to transform a tensor on one hand but undo the transform at the end.

  2. In ImageTuple.apply_tfms, tfms is applied on self.img1 and self.img2, which are instances of After that, why is not updated accordingly? (in the way that you do in ImageTuple.__init__, i.e. = -1+2*

  3. Following up on Q2, does ImageTuple.apply_tfms actually apply on torch.Tensor or PIL.Image? It seems to me the tfms is applied on torch.Tensor, in contrary to PyTorch practice where transforms is applied on PIL.Image.

Code Snippet

class TargetTupleList(ItemList):
    def reconstruct(self, t:Tensor): 
        if len(t.size()) == 0: return t
        # Image input is tensor (C, H, W) -- [0-1]
        return ImageTuple(Image(t[0]/2+0.5),Image(t[1]/2+0.5))

class ImageTuple(ItemBase):
    def __init__(self, img1, img2):
        # img1, img2 =
        self.img1,self.img2 = img1,img2
        # is [0 - 1] tensor, converted to [-0.5 - 0.5]
        self.obj, = (img1,img2),[-1+2*,-1+2*]

    def apply_tfms(self, tfms, **kwargs):
        self.img1 = self.img1.apply_tfms(tfms, **kwargs)
        self.img2 = self.img2.apply_tfms(tfms, **kwargs)
        return self