docstr: The same TorchVision transforms are applied across all rames in the clip (e.g.
  position of the random crop is constant across clip frames). Transforms we
  apply include:
  
      Temporal Subsampling: unofromly sunsample `video_num_subsampled` frames
      Scaling: scale rgb [0, 255] to [0, 1]
      Normalization: if `notmalize`, normalize with imagenet mean and scale
      Augmentations:
          - In 'train' random augmentations -- (resized) crop, horizontal flip)
          - In 'val' -- center crop only
          - In 'test' -- no augmentations
docstr_tok: ["The","same","TorchVision","transforms","are","applied","across","all","rames","in","the","clip","(","e.g",".","position","of","the","random","crop","is","constant","across","clip","frames",")",".","Transforms","we","apply","include",":","Temporal","Subsampling",":","unofromly","sunsample","`","video_num_subsampled","`","frames","Scaling",":","scale","rgb","[","0",",","255","]","to","[","0",",","1","]","Normalization",":","if","`","notmalize","`",",","normalize","with","imagenet","mean","and","scale","Augmentations",":","-","In","'train","'","random","augmentations","--","(","resized",")","crop",",","horizontal","flip",")","-","In","'val","'","--","center","crop","only","-","In","'test","'","--","no","augmentations"]
code: def _video_transform(
      self, mode: str
  ) -> torchvision.transforms.Compose:
      """
      The same TorchVision transforms are applied across all rames in the clip (e.g.
      position of the random crop is constant across clip frames). Transforms we
      apply include:
  
          Temporal Subsampling: unofromly sunsample `video_num_subsampled` frames
          Scaling: scale rgb [0, 255] to [0, 1]
          Normalization: if `notmalize`, normalize with imagenet mean and scale
          Augmentations:
              - In 'train' random augmentations -- (resized) crop, horizontal flip)
              - In 'val' -- center crop only
              - In 'test' -- no augmentations
      """
      if self.video_num_subsampled is None:
          # No subsampling for val and test modes
          temporal_subsampling = []
      elif isinstance(self.video_num_subsampled, int):
          temporal_subsampling = [
              UniformTemporalSubsample(
                  num_samples=self.video_num_subsampled
              )
          ]
      elif mode == "train":
          temporal_subsampling = [
              RandomChoice(
                  [
                      UniformTemporalSubsample(num_samples=num_samples)
                      for num_samples in self.video_num_subsampled
                  ]
              )
          ]
      else:
          temporal_subsampling = [
              UniformTemporalSubsample(num_samples=self.max_len)
          ]
  
      scaling = [Lambda(lambda x: x / 255.0)]
      normalization = (
          [Normalize(self.video_means, self.video_stds)]
          if self.normalize
          else []
      )
      if mode == "train":
          augmentations = [
              RandomChoice(
                  [
                      RandomCrop(
                          size=self.video_crop_size,
                          pad_if_needed=True,
                          padding_mode="edge",
                      ),
                      RandomResizedCrop(
                          size=self.video_crop_size, scale=(0.6, 1)
                      ),
                  ]
              ),
              RandomHorizontalFlip(p=0.5),
          ]
      elif mode == "val":
          augmentations = [CenterCrop(size=self.video_crop_size)]
      else:
          augmentations = []  # no augmentations for val and test modes
  
      video_transforms = ApplyTransformToKey(
          key="video",
          transform=Compose(
              temporal_subsampling
              + scaling
              + normalization
              + augmentations
          ),
      )
      return Compose([video_transforms, RemoveKey("audio")])
  
imports: import os
  from typing import List, Optional, Union
  import pytorchvideo.data
  import torch
  import torch.nn
  import torch.utils.data
  import torchvision
  from datamodules.video_data_api import KineticsDataset
  from pytorch_lightning import LightningDataModule
  from pytorchvideo.transforms import ApplyTransformToKey, Normalize, RemoveKey, UniformTemporalSubsample
  from torchvision.transforms import CenterCrop, Compose, Lambda, RandomChoice, RandomCrop, RandomHorizontalFlip, RandomResizedCrop
label_desc: Use image node_id 8 for calling the KineticsDataModule obj's underlying member method code with example usage: obj._video_transform(mode) and returns: Compose