code: def make_ucsd_dataset(
      path: Path, split: str | Split | None = None
  ) -> DataFrame:
      """Create UCSD Pedestrian dataset by parsing the file structure.
  
      The files are expected to follow the structure:
          path/to/dataset/category/split/video_id/image_filename.tif
          path/to/dataset/category/split/video_id_gt/mask_filename.bmp
  
      Args:
          root (Path): Path to dataset
          split (str | Split | None, optional): Dataset split (ie., either train or test). Defaults to None.
  
      Example:
          The following example shows how to get testing samples from UCSDped2 category:
  
          >>> root = Path('./UCSDped')
          >>> category = 'UCSDped2'
          >>> path = root / category
          >>> path
          PosixPath('UCSDped/UCSDped2')
  
          >>> samples = make_ucsd_dataset(path, split='test')
          >>> samples.head()
             root             folder image_path                    mask_path                         split
          0  UCSDped/UCSDped2 Test   UCSDped/UCSDped2/Test/Test001 UCSDped/UCSDped2/Test/Test001_gt  test
          1  UCSDped/UCSDped2 Test   UCSDped/UCSDped2/Test/Test002 UCSDped/UCSDped2/Test/Test002_gt  test
          ...
  
      Returns:
          DataFrame: an output dataframe containing samples for the requested split (ie., train or test)
      """
      folders = [
          filename
          for filename in sorted(path.glob("*/*"))
          if filename.is_dir()
      ]
      folders = [
          folder for folder in folders if list(folder.glob("*.tif"))
      ]
  
      samples_list = [
          (str(path),) + folder.parts[-2:] for folder in folders
      ]
      samples = DataFrame(
          samples_list, columns=["root", "folder", "image_path"]
      )
  
      samples.loc[samples.folder == "Test", "mask_path"] = (
          samples.image_path.str.split(".").str[0] + "_gt"
      )
      samples.loc[samples.folder == "Test", "mask_path"] = (
          samples.root + "/" + samples.folder + "/" + samples.mask_path
      )
      samples.loc[samples.folder == "Train", "mask_path"] = ""
  
      samples["image_path"] = (
          samples.root + "/" + samples.folder + "/" + samples.image_path
      )
  
      samples.loc[samples.folder == "Train", "split"] = "train"
      samples.loc[samples.folder == "Test", "split"] = "test"
  
      if split:
          samples = samples[samples.split == split]
          samples = samples.reset_index(drop=True)
  
      return samples
  
imports: from __future__ import annotations
  import logging
  from pathlib import Path
  from shutil import move
  from typing import Any, Callable
  import albumentations
  import cv2
  import numpy
  import torch
  from pandas import DataFrame
  from torch import Tensor
  from anomalib.data.base import AnomalibVideoDataModule, AnomalibVideoDataset
  from anomalib.data.base.video import VideoTargetFrame
  from anomalib.data.task_type import TaskType
  from anomalib.data.utils import DownloadInfo, InputNormalizationMethod, Split, ValSplitMode, download_and_extract, get_transforms, read_image
  from anomalib.data.utils.video import ClipsIndexer
label_desc: Use image node_id 1 for calling a global function with example usage: make_ucsd_dataset(path, split) and returns: samples