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",",",">",">",">",")"]
code: def __init__(
      self,
      input_size: int = 64,
      cj_prob: float = 0.8,
      cj_bright: float = 0.4,
      cj_contrast: float = 0.4,
      cj_sat: float = 0.4,
      cj_hue: float = 0.4,
      min_scale: float = 0.08,
      random_gray_scale: float = 0.2,
      hf_prob: float = 0.5,
      n_grid: int = 3,
      normalize: dict = imagenet_normalize,
  ):
      _deprecation_warning_collate_functions()
      super(PIRLCollateFunction, self).__init__()
  
      if isinstance(input_size, tuple):
          input_size_ = max(input_size)
      else:
          input_size_ = input_size
  
      color_jitter = T.ColorJitter(
          cj_bright, cj_contrast, cj_sat, cj_hue
      )
  
      # Transform for transformed jigsaw image
      transform = [
          T.RandomHorizontalFlip(p=hf_prob),
          T.RandomApply([color_jitter], p=cj_prob),
          T.RandomGrayscale(p=random_gray_scale),
          T.ToTensor(),
      ]
  
      if normalize:
          transform += [
              T.Normalize(mean=normalize["mean"], std=normalize["std"])
          ]
  
      # Cropping and normalisation for untransformed image
      self.no_augment = T.Compose(
          [
              T.RandomResizedCrop(
                  size=input_size, scale=(min_scale, 1.0)
              ),
              T.ToTensor(),
              T.Normalize(mean=normalize["mean"], std=normalize["std"]),
          ]
      )
      self.jigsaw = Jigsaw(
          n_grid=n_grid,
          img_size=input_size_,
          crop_size=int(input_size_ // n_grid),
          transform=T.Compose(transform),
      )
  
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 1 to create a new PIRLCollateFunction object from inherited base classes: nn with example: obj = PIRLCollateFunction(input_size, cj_prob, cj_bright, cj_contrast, cj_sat, cj_hue, min_scale, random_gray_scale, hf_prob, n_grid, normalize)