class_docstr: Interface specifying what a ClassyVision video dataset is expected to provide.
  
  This dataset considers every video as a collection of video clips of fixed size,
  specified by ``frames_per_clip``, where the step in frames between each clip
  is given by ``step_between_clips``. It uses a clip sampler to sample
  a specified number of clips (``clips_per_video``) from each video.
  For training set, a random clip sampler is used to
  sample a small number of clips (e.g. 1) from each video
  For testing set, a uniform clip sampler is used to evenly sample a large
  number of clips (e.g. 10) from the video.
  
  To give an example, for 2 videos with 10 and 15 frames respectively,
  if ``frames_per_clip=5`` and ``step_between_clips=5``, the dataset size
  will be (2 + 3) = 5, where the first two elements will come from video 1,
  and the next three elements from video 2. Note that we drop clips which do
  not have exactly ``frames_per_clip`` elements, so not all frames in a video
  may be present.
class_docstr_tok: ["Interface","specifying","what","a","ClassyVision","video","dataset","is","expected","to","provide",".","This","dataset","considers","every","video","as","a","collection","of","video","clips","of","fixed","size",",","specified","by","``","frames_per_clip","``",",","where","the","step","in","frames","between","each","clip","is","given","by","``","step_between_clips","``",".","It","uses","a","clip","sampler","to","sample","a","specified","number","of","clips","(","``","clips_per_video","``",")","from","each","video",".","For","training","set",",","a","random","clip","sampler","is","used","to","sample","a","small","number","of","clips","(","e.g",".","1",")","from","each","video","For","testing","set",",","a","uniform","clip","sampler","is","used","to","evenly","sample","a","large","number","of","clips","(","e.g",".","10",")","from","the","video",".","To","give","an","example",",","for","2","videos","with","10","and","15","frames","respectively",",","if","``","frames_per_clip=5","``","and","``","step_between_clips=5","``",",","the","dataset","size","will","be","(","2","+","3",")","=","5",",","where","the","first","two","elements","will","come","from","video","1",",","and","the","next","three","elements","from","video","2",".","Note","that","we","drop","clips","which","do","not","have","exactly","``","frames_per_clip","``","elements",",","so","not","all","frames","in","a","video","may","be","present","."]
docstr: Load pre-computed video dataset meta data.
  
  Video dataset meta data computation takes minutes on small dataset and hours
  on large dataset, and thus is time-consuming. However, it only needs to be
  computed once, and can be saved into a file via :func:`save_metadata`.
  
  The format of meta data is defined in `TorchVision <https://github.com/
  pytorch/vision/blob/master/torchvision/datasets/video_utils.py#L131/>`_.
  
  For each video, meta data contains the video file path, presentation
  timestamps of all video frames, and video fps.
  
  Args:
      filepath: file path of pre-computed meta data
      video_dir: If provided, the folder where video files are stored.
      update_file_path: If true, replace the directory part of video file path
          in meta data with the actual video directory provided in `video_dir`.
          This is necessary for successsfully reusing pre-computed meta data
          when video directory has been moved and is no longer consitent
          with the full video file path saved in the meta data.
docstr_tok: ["Load","pre-computed","video","dataset","meta","data",".","Video","dataset","meta","data","computation","takes","minutes","on","small","dataset","and","hours","on","large","dataset",",","and","thus","is","time-consuming",".","However",",","it","only","needs","to","be","computed","once",",","and","can","be","saved","into","a","file","via",":","func",":","`","save_metadata","`",".","The","format","of","meta","data","is","defined","in","`","TorchVision","<","https",":","\/\/github.com\/","pytorch\/vision\/blob\/master\/torchvision\/datasets\/video_utils.py","#","L131\/",">","`","_",".","For","each","video",",","meta","data","contains","the","video","file","path",",","presentation","timestamps","of","all","video","frames",",","and","video","fps",".","Args",":","filepath",":","file","path","of","pre-computed","meta","data","video_dir",":","If","provided",",","the","folder","where","video","files","are","stored",".","update_file_path",":","If","true",",","replace","the","directory","part","of","video","file","path","in","meta","data","with","the","actual","video","directory","provided","in","`","video_dir","`",".","This","is","necessary","for","successsfully","reusing","pre-computed","meta","data","when","video","directory","has","been","moved","and","is","no","longer","consitent","with","the","full","video","file","path","saved","in","the","meta","data","."]
code: def load_metadata(
      cls,
      filepath: str,
      video_dir: Optional[str] = None,
      update_file_path: bool = False,
  ) -> Dict[str, Any]:
      """Load pre-computed video dataset meta data.
  
      Video dataset meta data computation takes minutes on small dataset and hours
      on large dataset, and thus is time-consuming. However, it only needs to be
      computed once, and can be saved into a file via :func:`save_metadata`.
  
      The format of meta data is defined in `TorchVision <https://github.com/
      pytorch/vision/blob/master/torchvision/datasets/video_utils.py#L131/>`_.
  
      For each video, meta data contains the video file path, presentation
      timestamps of all video frames, and video fps.
  
      Args:
          filepath: file path of pre-computed meta data
          video_dir: If provided, the folder where video files are stored.
          update_file_path: If true, replace the directory part of video file path
              in meta data with the actual video directory provided in `video_dir`.
              This is necessary for successsfully reusing pre-computed meta data
              when video directory has been moved and is no longer consitent
              with the full video file path saved in the meta data.
      """
      metadata = torch.load(filepath)
      if video_dir is not None and update_file_path:
          # video path in meta data can be computed in a different root video folder
          # If we use a different root video folder, we need to update the video paths
          assert os.path.exists(video_dir), (
              "folder does not exist: %s" % video_dir
          )
          for idx, video_path in enumerate(metadata["video_paths"]):
              # video path template is $VIDEO_DIR/$CLASS_NAME/$VIDEO_FILE
              dirname, filename = os.path.split(video_path)
              _, class_name = os.path.split(dirname)
              metadata["video_paths"][idx] = os.path.join(
                  video_dir, class_name, filename
              )
      return metadata
  
imports: import logging
  import os
  from typing import Any, Callable, Dict, Optional
  import torch
  from classy_vision.generic.distributed_util import get_rank, get_world_size
  from torch.utils.data import Sampler
  from torchvision import get_video_backend
  from torchvision.datasets.samplers.clip_sampler import DistributedSampler, RandomClipSampler, UniformClipSampler
  from .classy_dataset import ClassyDataset
label_desc: Use image node_id 3 for calling the ClassyVideoDataset obj's underlying member method code with example usage: obj.load_metadata(cls, filepath, video_dir, update_file_path) and returns: metadata