class_docstr: Implements the global and local view augmentations for DINO [0].
  
  This class generates two global and a user defined number of local views
  for each image in a batch. The code is adapted from [1].
  
  - [0]: DINO, 2021, https://arxiv.org/abs/2104.14294
  - [1]: https://github.com/facebookresearch/dino
  
  Attributes:
      global_crop_size:
          Crop size of the global views.
      global_crop_scale:
          Tuple of min and max scales relative to global_crop_size.
      local_crop_size:
          Crop size of the local views.
      local_crop_scale:
          Tuple of min and max scales relative to local_crop_size.
      n_local_views:
          Number of generated local views.
      hf_prob:
          Probability that horizontal flip is applied.
      vf_prob:
          Probability that vertical flip is applied.
      rr_prob:
          Probability that random rotation is applied.
      rr_degrees:
          Range of degrees to select from for random rotation. If rr_degrees is None,
          images are rotated by 90 degrees. If rr_degrees is a (min, max) tuple,
          images are rotated by a random angle in [min, max]. If rr_degrees is a
          single number, images are rotated by a random angle in
          [-rr_degrees, +rr_degrees]. All rotations are counter-clockwise.
      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.
      random_gray_scale:
          Probability of conversion to grayscale.
      gaussian_blur:
          Tuple of probabilities to apply gaussian blur on the different
          views. The input is ordered as follows:
          (global_view_0, global_view_1, local_views)
      kernel_size:
          Will be deprecated in favor of `sigmas` argument. If set, the old behavior applies and `sigmas` is ignored.
          Used to calculate sigma of gaussian blur with kernel_size * input_size.
      kernel_scale:
          Old argument. Value is deprecated in favor of sigmas. If set, the old behavior applies and `sigmas` is ignored.
          Used to scale the `kernel_size` of a factor of `kernel_scale`
      sigmas:
          Tuple of min and max value from which the std of the gaussian kernel is sampled.
          Is ignored if `kernel_size` is set.
      solarization:
          Probability to apply solarization on the second global view.
      normalize:
          Dictionary with 'mean' and 'std' for torchvision.transforms.Normalize.
class_docstr_tok: ["Implements","the","global","and","local","view","augmentations","for","DINO","[","0","]",".","This","class","generates","two","global","and","a","user","defined","number","of","local","views","for","each","image","in","a","batch",".","The","code","is","adapted","from","[","1","]",".","-","[","0","]",":","DINO",",","2021",",","https",":","\/\/arxiv.org\/abs\/2104.14294","-","[","1","]",":","https",":","\/\/github.com\/facebookresearch\/dino","Attributes",":","global_crop_size",":","Crop","size","of","the","global","views",".","global_crop_scale",":","Tuple","of","min","and","max","scales","relative","to","global_crop_size",".","local_crop_size",":","Crop","size","of","the","local","views",".","local_crop_scale",":","Tuple","of","min","and","max","scales","relative","to","local_crop_size",".","n_local_views",":","Number","of","generated","local","views",".","hf_prob",":","Probability","that","horizontal","flip","is","applied",".","vf_prob",":","Probability","that","vertical","flip","is","applied",".","rr_prob",":","Probability","that","random","rotation","is","applied",".","rr_degrees",":","Range","of","degrees","to","select","from","for","random","rotation",".","If","rr_degrees","is","None",",","images","are","rotated","by","90","degrees",".","If","rr_degrees","is","a","(","min",",","max",")","tuple",",","images","are","rotated","by","a","random","angle","in","[","min",",","max","]",".","If","rr_degrees","is","a","single","number",",","images","are","rotated","by","a","random","angle","in","[","-rr_degrees",",","+rr_degrees","]",".","All","rotations","are","counter-clockwise",".","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",".","random_gray_scale",":","Probability","of","conversion","to","grayscale",".","gaussian_blur",":","Tuple","of","probabilities","to","apply","gaussian","blur","on","the","different","views",".","The","input","is","ordered","as","follows",":","(","global_view_0",",","global_view_1",",","local_views",")","kernel_size",":","Will","be","deprecated","in","favor","of","`","sigmas","`","argument",".","If","set",",","the","old","behavior","applies","and","`","sigmas","`","is","ignored",".","Used","to","calculate","sigma","of","gaussian","blur","with","kernel_size","*","input_size",".","kernel_scale",":","Old","argument",".","Value","is","deprecated","in","favor","of","sigmas",".","If","set",",","the","old","behavior","applies","and","`","sigmas","`","is","ignored",".","Used","to","scale","the","`","kernel_size","`","of","a","factor","of","`","kernel_scale","`","sigmas",":","Tuple","of","min","and","max","value","from","which","the","std","of","the","gaussian","kernel","is","sampled",".","Is","ignored","if","`","kernel_size","`","is","set",".","solarization",":","Probability","to","apply","solarization","on","the","second","global","view",".","normalize",":","Dictionary","with","'mean","'","and","'std","'","for","torchvision.transforms.Normalize","."]
code: def __init__(
      self,
      global_crop_size=224,
      global_crop_scale=(0.4, 1.0),
      local_crop_size=96,
      local_crop_scale=(0.05, 0.4),
      n_local_views=6,
      hf_prob=0.5,
      vf_prob=0,
      rr_prob=0,
      rr_degrees: Union[None, float, Tuple[float, float]] = None,
      cj_prob=0.8,
      cj_bright=0.4,
      cj_contrast=0.4,
      cj_sat=0.2,
      cj_hue=0.1,
      random_gray_scale=0.2,
      gaussian_blur=(1.0, 0.1, 0.5),
      kernel_size: Optional[float] = None,
      kernel_scale: Optional[float] = None,
      sigmas: Tuple[float, float] = (0.1, 2),
      solarization_prob=0.2,
      normalize=imagenet_normalize,
  ):
      flip_and_color_jitter = T.Compose(
          [
              T.RandomHorizontalFlip(p=hf_prob),
              T.RandomVerticalFlip(p=vf_prob),
              random_rotation_transform(
                  rr_prob=rr_prob, rr_degrees=rr_degrees
              ),
              T.RandomApply(
                  [
                      T.ColorJitter(
                          brightness=cj_bright,
                          contrast=cj_contrast,
                          saturation=cj_sat,
                          hue=cj_hue,
                      )
                  ],
                  p=cj_prob,
              ),
              T.RandomGrayscale(p=random_gray_scale),
          ]
      )
      normalize = T.Compose(
          [
              T.ToTensor(),
              T.Normalize(mean=normalize["mean"], std=normalize["std"]),
          ]
      )
      global_crop = T.RandomResizedCrop(
          global_crop_size,
          scale=global_crop_scale,
          interpolation=Image.BICUBIC,
      )
  
      # first global crop
      global_transform_0 = T.Compose(
          [
              global_crop,
              flip_and_color_jitter,
              GaussianBlur(
                  kernel_size=kernel_size,
                  scale=kernel_scale,
                  sigmas=sigmas,
                  prob=gaussian_blur[0],
              ),
              normalize,
          ]
      )
  
      # second global crop
      global_transform_1 = T.Compose(
          [
              global_crop,
              flip_and_color_jitter,
              GaussianBlur(
                  kernel_size=kernel_size,
                  scale=kernel_scale,
                  sigmas=sigmas,
                  prob=gaussian_blur[1],
              ),
              RandomSolarization(prob=solarization_prob),
              normalize,
          ]
      )
  
      # transformation for the local small crops
      local_transform = T.Compose(
          [
              T.RandomResizedCrop(
                  local_crop_size,
                  scale=local_crop_scale,
                  interpolation=Image.BICUBIC,
              ),
              flip_and_color_jitter,
              GaussianBlur(
                  kernel_size=kernel_size,
                  scale=kernel_scale,
                  sigmas=sigmas,
                  prob=gaussian_blur[2],
              ),
              normalize,
          ]
      )
      local_transforms = [local_transform] * n_local_views
  
      transforms = [global_transform_0, global_transform_1]
      transforms.extend(local_transforms)
      super().__init__(transforms)
  
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 DINOCollateFunction object from inherited base classes: MultiViewCollateFunction with example: obj = DINOCollateFunction(global_crop_size, global_crop_scale, local_crop_size, local_crop_scale, n_local_views, hf_prob, vf_prob, rr_prob, rr_degrees, cj_prob, cj_bright, cj_contrast, cj_sat, cj_hue, random_gray_scale, gaussian_blur, kernel_size, kernel_scale, sigmas, solarization_prob, normalize)