code: def _load_dataset_from_folder(
      root: str,
      transform,
      is_valid_file: Optional[Callable[[str], bool]] = None,
      tqdm_args: Dict[str, Any] = None,
      num_workers_video_frame_counting: int = 0,
  ):
      """Initializes dataset from folder.
  
      Args:
          root: (str) Root directory path
          transform: (torchvision.transforms.Compose) image transformations
  
      Returns:
          Dataset consisting of images/videos in the root directory.
  
      Raises:
          ValueError: If the specified dataset doesn't exist
  
      """
      if not os.path.exists(root):
          raise ValueError(
              f"The input directory {root} does not exist!"
          )
  
      # if there is a video in the input directory but we do not have
      # the right dependencies, raise a ValueError
      contains_videos = _contains_videos(root, VIDEO_EXTENSIONS)
      if contains_videos and not VIDEO_DATASET_AVAILABLE:
          raise ValueError(
              f"The input directory {root} contains videos "
              "but the VideoDataset is not available. \n"
              "Make sure you have installed the right "
              "dependencies. The error from the imported "
              f"module was: {VIDEO_DATASET_ERRORMSG}"
          )
  
      if contains_videos:
          # root contains videos -> create a video dataset
          dataset = VideoDataset(
              root,
              extensions=VIDEO_EXTENSIONS,
              transform=transform,
              is_valid_file=is_valid_file,
              tqdm_args=tqdm_args,
              num_workers=num_workers_video_frame_counting,
          )
      elif _contains_subdirs(root):
          # root contains subdirectories -> create an image folder dataset
          dataset = datasets.ImageFolder(
              root, transform=transform, is_valid_file=is_valid_file
          )
      else:
          # root contains plain images -> create a folder dataset
          dataset = DatasetFolder(
              root,
              extensions=IMG_EXTENSIONS,
              transform=transform,
              is_valid_file=is_valid_file,
          )
  
      return dataset
  
file_path: lightly/lightly/data/_helpers.py
imports: import os
  from typing import Any, Callable, Dict, List, Optional, Set
  from torchvision import datasets
  from lightly.data._image import DatasetFolder
label_desc: Use image node_id 5 for calling a global function with example usage: _load_dataset_from_folder(root, transform, is_valid_file, tqdm_args, num_workers_video_frame_counting) and returns: dataset