docstr: Kinetics datamodule.
  
  Args:
      data_dir: directory containing the kinetics dataset.
      train_batch_size, val_batch_size: batch size for train/val set.
      clip_duration: duration of sampled clip for each video.
      video_num_subsampled: number of frames to subsample from each video using
          `UniformTemporalSubsample`. If None, no subsampling is applied.
      normalize: images are always scaled (/255) and optionally normalized to
      (approximately) zero mean and unit std.
      train_clip_sampler: choose "random" for typical classification objective.
          Choose "uniform" to sample all clips of a given duration from video,
          useful for SSL objective. See `pytorchvideo.data.make_clip_sampler` for
          more details.
      num_workers: number of parallel processes fetching data.
      pin_memory: if `True`, the data loader will copy Tensors
          into device/CUDA pinned memory before returning them.
          See pytorch DataLoader for more details.
docstr_tok: ["Kinetics","datamodule",".","Args",":","data_dir",":","directory","containing","the","kinetics","dataset",".","train_batch_size",",","val_batch_size",":","batch","size","for","train\/val","set",".","clip_duration",":","duration","of","sampled","clip","for","each","video",".","video_num_subsampled",":","number","of","frames","to","subsample","from","each","video","using","`","UniformTemporalSubsample","`",".","If","None",",","no","subsampling","is","applied",".","normalize",":","images","are","always","scaled","(","\/255",")","and","optionally","normalized","to","(","approximately",")","zero","mean","and","unit","std",".","train_clip_sampler",":","choose","``","random","''","for","typical","classification","objective",".","Choose","``","uniform","''","to","sample","all","clips","of","a","given","duration","from","video",",","useful","for","SSL","objective",".","See","`","pytorchvideo.data.make_clip_sampler","`","for","more","details",".","num_workers",":","number","of","parallel","processes","fetching","data",".","pin_memory",":","if","`","True","`",",","the","data","loader","will","copy","Tensors","into","device\/CUDA","pinned","memory","before","returning","them",".","See","pytorch","DataLoader","for","more","details","."]
code: def __init__(
      self,
      data_dir: str,
      train_batch_size: int = 4,
      val_batch_size: int = 4,
      clip_duration: int = 2,
      video_num_subsampled: Optional[Union[int, List[int]]] = None,
      normalize: bool = False,
      train_clip_sampler: str = "uniform",
      num_workers: int = 2,
      pin_memory: bool = True,
  ) -> None:
      """Kinetics datamodule.
  
      Args:
          data_dir: directory containing the kinetics dataset.
          train_batch_size, val_batch_size: batch size for train/val set.
          clip_duration: duration of sampled clip for each video.
          video_num_subsampled: number of frames to subsample from each video using
              `UniformTemporalSubsample`. If None, no subsampling is applied.
          normalize: images are always scaled (/255) and optionally normalized to
          (approximately) zero mean and unit std.
          train_clip_sampler: choose "random" for typical classification objective.
              Choose "uniform" to sample all clips of a given duration from video,
              useful for SSL objective. See `pytorchvideo.data.make_clip_sampler` for
              more details.
          num_workers: number of parallel processes fetching data.
          pin_memory: if `True`, the data loader will copy Tensors
              into device/CUDA pinned memory before returning them.
              See pytorch DataLoader for more details.
      """
  
      super().__init__()
      self.data_dir = data_dir
      self.train_batch_size = train_batch_size
      self.val_batch_size = val_batch_size
      self.clip_duration = clip_duration
      self.num_workers = num_workers
      self.pin_memory = pin_memory
      self.train_clip_sampler = train_clip_sampler
      self.video_num_subsampled = video_num_subsampled
      if video_num_subsampled is not None:
          self.max_len = (
              video_num_subsampled
              if isinstance(video_num_subsampled, int)
              else max(video_num_subsampled)
          )
      # The mean and std are the default in pytorchvideo.transforms.create_video_transform
      # Note data is first /255 and then pytorchvideo.transforms.Normalize-d
      # Omnivision uses [123.675, 116.28, 103.53]; [58.395, 57.12, 57.375]
      self.normalize = normalize
      if normalize:
          self.video_means = (0.45, 0.45, 0.45)
          self.video_stds = (0.225, 0.225, 0.225)
      self.video_crop_size = 256
      self.video_min_short_side_scale = 256
      self.video_max_short_side_scale = 320
  
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 1 to create a new KineticsDataModule object from inherited base classes: LightningDataModule with example: obj = KineticsDataModule(data_dir, train_batch_size, val_batch_size, clip_duration, video_num_subsampled, normalize, train_clip_sampler, num_workers, pin_memory)