class_docstr: Something-Something v2 (SSV2) video loader. Construct the SSV2 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: ["Something-Something","v2","(","SSV2",")","video","loader",".","Construct","the","SSV2","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 video loader.
docstr_tok: ["Construct","the","video","loader","."]
code: def _construct_loader(self):
      """
      Construct the video loader.
      """
      # Loading label names.
      with pathmgr.open(
          os.path.join(
              self.cfg.DATA.PATH_TO_DATA_DIR,
              "something-something-v2-labels.json",
          ),
          "r",
      ) as f:
          label_dict = json.load(f)
  
      # Loading labels.
      label_file = os.path.join(
          self.cfg.DATA.PATH_TO_DATA_DIR,
          "something-something-v2-{}.json".format(
              "train" if self.mode == "train" else "validation"
          ),
      )
      with pathmgr.open(label_file, "r") as f:
          label_json = json.load(f)
  
      self._video_names = []
      self._labels = []
      for video in label_json:
          video_name = video["id"]
          template = video["template"]
          template = template.replace("[", "")
          template = template.replace("]", "")
          label = int(label_dict[template])
          self._video_names.append(video_name)
          self._labels.append(label)
  
      path_to_file = os.path.join(
          self.cfg.DATA.PATH_TO_DATA_DIR,
          "{}.csv".format("train" if self.mode == "train" else "val"),
      )
      assert pathmgr.exists(path_to_file), "{} dir not found".format(
          path_to_file
      )
  
      self._path_to_videos, _ = utils.load_image_lists(
          path_to_file, self.cfg.DATA.PATH_PREFIX
      )
  
      assert len(self._path_to_videos) == len(self._video_names), (
          len(self._path_to_videos),
          len(self._video_names),
      )
  
      # From dict to list.
      new_paths, new_labels = [], []
      for index in range(len(self._video_names)):
          if self._video_names[index] in self._path_to_videos:
              new_paths.append(
                  self._path_to_videos[self._video_names[index]]
              )
              new_labels.append(self._labels[index])
  
      self._labels = new_labels
      self._path_to_videos = new_paths
  
      # Extend self when self._num_clips > 1 (during testing).
      self._path_to_videos = list(
          chain.from_iterable(
              [[x] * self._num_clips for x in self._path_to_videos]
          )
      )
      self._labels = list(
          chain.from_iterable(
              [[x] * self._num_clips for x in self._labels]
          )
      )
      self._spatial_temporal_idx = list(
          chain.from_iterable(
              [
                  range(self._num_clips)
                  for _ in range(len(self._path_to_videos))
              ]
          )
      )
      logger.info(
          "Something-Something V2 dataloader constructed "
          " (size: {}) from {}".format(
              len(self._path_to_videos), path_to_file
          )
      )
  
file_path: SlowFast/slowfast/datasets/ssv2.py
imports: import json
  import numpy
  import os
  import random
  from itertools import chain
  import torch
  import torch.utils.data
  import slowfast.utils.logging
  from slowfast.utils.env import pathmgr
  from .None import utils
  from .build import DATASET_REGISTRY
label_desc: Use image node_id 2 for calling the Ssv2 obj's underlying member method code with example usage: obj._construct_loader() without return types