def create_dset(patchH, patchW, PatchperImage, settype='train'):
  """
  patchH: Patch height
  patchW: Patch width
  PatchperImage: Number of patches per image
  settype: Can be either train or test
  """
  if settype == 'train':
    Datapath = '//images/'
    # 2 different annotations by different oplthalmologists
    Labelpath = '//labels/'
  elif settype == 'test':
    Datapath = 'images/'
    # 2 different annotations by different oplthalmologists
    Labelpath = '1st_manual/'
  else:
    raise ValueError("settype can be either 'test' or 'train'")
  
  images = torch.DoubleTensor(20*PatchperImage,3*patchH*patchW) # 20 such images
  labels = torch.DoubleTensor(20*PatchperImage,patchH*patchW) 
  t_no = 0
  for img_no in range(20):
      if settype == 'train':
        dp = Datapath + str(img_no+21) + '_training.tif'
        lp = Labelpath + str(img_no+21) + '_manual1.gif'
      elif settype == 'test':
        dp = Datapath + "%02d"%(img_no+1) + '_test.tif'
        lp = Labelpath + "%02d"%(img_no+1) + '_manual1.gif'
      imD = Image.open(dp)
      imD = np.array(imD)    

      imL = Image.open(lp)
      imL = np.array(imL)
      imL = np.reshape(imL, (imL.shape[0],imL.shape[1],1))
      imD,imL = img_transfer(imD,imL, patchH, patchW, PatchperImage)
      imD = imD/255.0
      imL = imL/255.0
      for i in range(PatchperImage):
          images[t_no] = torch.from_numpy(imD[i])
          labels[t_no] = torch.from_numpy(imL[i])
          t_no = t_no + 1
  return images, labels

here a function for creating patch , i want to do preprocessing steps should it be before the passing the patchs to the loader