class_docstr: LabeledVideoPaths contains pairs of video path and integer index label.
class_docstr_tok: ["LabeledVideoPaths","contains","pairs","of","video","path","and","integer","index","label","."]
docstr: Factory function that creates a LabeledVideoPaths object by parsing the structure
  of the given directory's subdirectories into the classification labels. It
  expects the directory format to be the following:
       dir_path/<class_name>/<video_name>.mp4
  
  Classes are indexed from 0 to the number of classes, alphabetically.
  
  E.g.
      dir_path/class_x/xxx.ext
      dir_path/class_x/xxy.ext
      dir_path/class_x/xxz.ext
      dir_path/class_y/123.ext
      dir_path/class_y/nsdf3.ext
      dir_path/class_y/asd932_.ext
  
  Would produce two classes labeled 0 and 1 with 3 videos paths associated with each.
  
  Args:
      dir_path (str): Root directory to the video class directories .
docstr_tok: ["Factory","function","that","creates","a","LabeledVideoPaths","object","by","parsing","the","structure","of","the","given","directory","'s","subdirectories","into","the","classification","labels",".","It","expects","the","directory","format","to","be","the","following",":","dir_path\/","<","class_name",">","\/","<","video_name",">",".mp4","Classes","are","indexed","from","0","to","the","number","of","classes",",","alphabetically",".","E.g",".","dir_path\/class_x\/xxx.ext","dir_path\/class_x\/xxy.ext","dir_path\/class_x\/xxz.ext","dir_path\/class_y\/123.ext","dir_path\/class_y\/nsdf3.ext","dir_path\/class_y\/asd932_.ext","Would","produce","two","classes","labeled","0","and","1","with","3","videos","paths","associated","with","each",".","Args",":","dir_path","(","str",")",":","Root","directory","to","the","video","class","directories","."]
code: def from_directory(cls, dir_path: str) -> LabeledVideoPaths:
      """
      Factory function that creates a LabeledVideoPaths object by parsing the structure
      of the given directory's subdirectories into the classification labels. It
      expects the directory format to be the following:
           dir_path/<class_name>/<video_name>.mp4
  
      Classes are indexed from 0 to the number of classes, alphabetically.
  
      E.g.
          dir_path/class_x/xxx.ext
          dir_path/class_x/xxy.ext
          dir_path/class_x/xxz.ext
          dir_path/class_y/123.ext
          dir_path/class_y/nsdf3.ext
          dir_path/class_y/asd932_.ext
  
      Would produce two classes labeled 0 and 1 with 3 videos paths associated with each.
  
      Args:
          dir_path (str): Root directory to the video class directories .
      """
      assert g_pathmgr.exists(dir_path), f"{dir_path} not found."
  
      # Find all classes based on directory names. These classes are then sorted and indexed
      # from 0 to the number of classes.
      classes = sorted(
          (
              f.name
              for f in pathlib.Path(dir_path).iterdir()
              if f.is_dir()
          )
      )
      class_to_idx = {classes[i]: i for i in range(len(classes))}
      video_paths_and_label = make_dataset(
          dir_path, class_to_idx, extensions=("mp4", "avi")
      )
      assert (
          len(video_paths_and_label) > 0
      ), f"Failed to load dataset from {dir_path}."
      return cls(video_paths_and_label)
  
file_path: pytorchvideo/pytorchvideo/data/labeled_video_paths.py
imports: from __future__ import annotations
  import os
  import pathlib
  from typing import List, Optional, Tuple
  from iopath.common.file_io import g_pathmgr
  from torchvision.datasets.folder import make_dataset
label_desc: Use image node_id 3 for calling the LabeledVideoPaths obj's underlying member method code with example usage: obj.from_directory(cls, dir_path) and returns: cls