class_docstr: Kinetics video loader. Construct the Kinetics video loader, then sample
  clips from the videos. For training and validation, a single clip is
  randomly sampled from every video with random cropping, scaling, and
  flipping. For testing, multiple clips are uniformaly sampled from every
  video with uniform cropping. For uniform cropping, we take the left, center,
  and right crop if the width is larger than height, or take top, center, and
  bottom crop if the height is larger than the width.
class_docstr_tok: ["Kinetics","video","loader",".","Construct","the","Kinetics","video","loader",",","then","sample","clips","from","the","videos",".","For","training","and","validation",",","a","single","clip","is","randomly","sampled","from","every","video","with","random","cropping",",","scaling",",","and","flipping",".","For","testing",",","multiple","clips","are","uniformaly","sampled","from","every","video","with","uniform","cropping",".","For","uniform","cropping",",","we","take","the","left",",","center",",","and","right","crop","if","the","width","is","larger","than","height",",","or","take","top",",","center",",","and","bottom","crop","if","the","height","is","larger","than","the","width","."]
docstr: Construct the Kinetics video loader with a given csv file. The format of
  the csv file is:
  ```
  path_to_video_1 label_1
  path_to_video_2 label_2
  ...
  path_to_video_N label_N
  ```
  Args:
      cfg (CfgNode): configs.
      mode (string): Options includes `train`, `val`, or `test` mode.
          For the train and val mode, the data loader will take data
          from the train or val set, and sample one clip per video.
          For the test mode, the data loader will take data from test set,
          and sample multiple clips per video.
      num_retries (int): number of retries.
docstr_tok: ["Construct","the","Kinetics","video","loader","with","a","given","csv","file",".","The","format","of","the","csv","file","is",":","``","`","path_to_video_1","label_1","path_to_video_2","label_2","...","path_to_video_N","label_N","``","`","Args",":","cfg","(","CfgNode",")",":","configs",".","mode","(","string",")",":","Options","includes","`","train","`",",","`","val","`",",","or","`","test","`","mode",".","For","the","train","and","val","mode",",","the","data","loader","will","take","data","from","the","train","or","val","set",",","and","sample","one","clip","per","video",".","For","the","test","mode",",","the","data","loader","will","take","data","from","test","set",",","and","sample","multiple","clips","per","video",".","num_retries","(","int",")",":","number","of","retries","."]
code: def __init__(self, cfg, mode, num_retries=100):
      """
      Construct the Kinetics video loader with a given csv file. The format of
      the csv file is:
      ```
      path_to_video_1 label_1
      path_to_video_2 label_2
      ...
      path_to_video_N label_N
      ```
      Args:
          cfg (CfgNode): configs.
          mode (string): Options includes `train`, `val`, or `test` mode.
              For the train and val mode, the data loader will take data
              from the train or val set, and sample one clip per video.
              For the test mode, the data loader will take data from test set,
              and sample multiple clips per video.
          num_retries (int): number of retries.
      """
      # Only support train, val, and test mode.
      assert mode in [
          "train",
          "val",
          "test",
      ], "Split '{}' not supported for Kinetics".format(mode)
      self.mode = mode
      self.cfg = cfg
      self.p_convert_gray = self.cfg.DATA.COLOR_RND_GRAYSCALE
      self.p_convert_dt = self.cfg.DATA.TIME_DIFF_PROB
      self._video_meta = {}
      self._num_retries = num_retries
      self._num_epoch = 0.0
      self._num_yielded = 0
      self.skip_rows = self.cfg.DATA.SKIP_ROWS
      self.use_chunk_loading = (
          True
          if self.mode in ["train"]
          and self.cfg.DATA.LOADER_CHUNK_SIZE > 0
          else False
      )
      self.dummy_output = None
      # For training or validation mode, one single clip is sampled from every
      # video. For testing, NUM_ENSEMBLE_VIEWS clips are sampled from every
      # video. For every clip, NUM_SPATIAL_CROPS is cropped spatially from
      # the frames.
      if self.mode in ["train", "val"]:
          self._num_clips = 1
      elif self.mode in ["test"]:
          self._num_clips = (
              cfg.TEST.NUM_ENSEMBLE_VIEWS * cfg.TEST.NUM_SPATIAL_CROPS
          )
  
      logger.info("Constructing Kinetics {}...".format(mode))
      self._construct_loader()
      self.aug = False
      self.rand_erase = False
      self.use_temporal_gradient = False
      self.temporal_gradient_rate = 0.0
      self.cur_epoch = 0
  
      if self.mode == "train" and self.cfg.AUG.ENABLE:
          self.aug = True
          if self.cfg.AUG.RE_PROB > 0:
              self.rand_erase = True
  
imports: import numpy
  import os
  import random
  import pandas
  import torch
  import torch.utils.data
  from torchvision import transforms
  import slowfast.utils.logging
  from slowfast.utils.env import pathmgr
  from .None import decoder
  from .None import transform
  from .None import utils
  from .None import video_container
  from .build import DATASET_REGISTRY
  from .random_erasing import RandomErasing
  from .transform import MaskingGenerator, MaskingGenerator3D, create_random_augment
label_desc: Use image node_id 1 to create a new Kinetics object from inherited base classes: torch.utils.data with example: obj = Kinetics(cfg, mode, num_retries)