class_docstr: Implements the transformations for PIRL [0]. The jigsaw augmentation
  is applied during the forward pass.
  
  - [0] PIRL, 2019: https://arxiv.org/abs/1912.01991
  
  Attributes:
      input_size:
          Size of the input image in pixels.
      cj_prob:
          Probability that color jitter is applied.
      cj_bright:
          How much to jitter brightness.
      cj_contrast:
          How much to jitter constrast.
      cj_sat:
          How much to jitter saturation.
      cj_hue:
          How much to jitter hue.
      min_scale:
          Minimum size of the randomized crop relative to the input_size.
      random_gray_scale:
          Probability of conversion to grayscale.
      hf_prob:
          Probability that horizontal flip is applied.
      n_grid:
          Sqrt of the number of grids in the jigsaw image.
      normalize:
          Dictionary with 'mean' and 'std' for torchvision.transforms.Normalize.
  
  Examples:
  
      >>> # PIRL for ImageNet
      >>> collate_fn = PIRLCollateFunction()
      >>>
      >>> # PIRL for CIFAR-10
      >>> collate_fn = PIRLCollateFunction(
      >>>     input_size=32,
      >>> )
class_docstr_tok: ["Implements","the","transformations","for","PIRL","[","0","]",".","The","jigsaw","augmentation","is","applied","during","the","forward","pass",".","-","[","0","]","PIRL",",","2019",":","https",":","\/\/arxiv.org\/abs\/1912.01991","Attributes",":","input_size",":","Size","of","the","input","image","in","pixels",".","cj_prob",":","Probability","that","color","jitter","is","applied",".","cj_bright",":","How","much","to","jitter","brightness",".","cj_contrast",":","How","much","to","jitter","constrast",".","cj_sat",":","How","much","to","jitter","saturation",".","cj_hue",":","How","much","to","jitter","hue",".","min_scale",":","Minimum","size","of","the","randomized","crop","relative","to","the","input_size",".","random_gray_scale",":","Probability","of","conversion","to","grayscale",".","hf_prob",":","Probability","that","horizontal","flip","is","applied",".","n_grid",":","Sqrt","of","the","number","of","grids","in","the","jigsaw","image",".","normalize",":","Dictionary","with","'mean","'","and","'std","'","for","torchvision.transforms.Normalize",".","Examples",":",">",">",">","#","PIRL","for","ImageNet",">",">",">","collate_fn","=","PIRLCollateFunction","(",")",">",">",">",">",">",">","#","PIRL","for","CIFAR-10",">",">",">","collate_fn","=","PIRLCollateFunction","(",">",">",">","input_size=32",",",">",">",">",")"]
docstr: Overriding the BaseCollateFunction class's forward method because
  for PIRL we need only one augmented batch, as opposed to both, which the
  BaseCollateFunction creates.
docstr_tok: ["Overriding","the","BaseCollateFunction","class","'s","forward","method","because","for","PIRL","we","need","only","one","augmented","batch",",","as","opposed","to","both",",","which","the","BaseCollateFunction","creates","."]
code: def forward(self, batch: List[tuple]):
      """Overriding the BaseCollateFunction class's forward method because
      for PIRL we need only one augmented batch, as opposed to both, which the
      BaseCollateFunction creates."""
      batch_size = len(batch)
  
      # list of transformed images
      img_transforms = [
          self.jigsaw(batch[i][0]).unsqueeze_(0)
          for i in range(batch_size)
      ]
      img = [
          self.no_augment(batch[i][0]).unsqueeze_(0)
          for i in range(batch_size)
      ]
      # list of labels
      labels = torch.LongTensor([item[1] for item in batch])
      # list of filenames
      fnames = [item[2] for item in batch]
  
      # tuple of transforms
      transforms = (torch.cat(img, 0), torch.cat(img_transforms, 0))
  
      return transforms, labels, fnames
  
imports: import math
  from multiprocessing import Value
  from typing import List, Optional, Tuple, Union
  from warnings import warn
  import torch
  import torch.nn
  import torchvision
  import torchvision.transforms
  from PIL import Image
  from lightly.transforms import GaussianBlur, Jigsaw, RandomSolarization
  from lightly.transforms.random_crop_and_flip_with_grid import RandomResizedCropAndFlip
  from lightly.transforms.rotation import random_rotation_transform
  from lightly.transforms.utils import IMAGENET_NORMALIZE
label_desc: Use image node_id 2 for calling the PIRLCollateFunction obj's underlying member method code with example usage: obj.forward(batch) and returns: transforms,  labels,  fnames