code: def make_avenue_dataset(
      root: Path, gt_dir: Path, split: Split | str | None = None
  ) -> DataFrame:
      """Create CUHK Avenue dataset by parsing the file structure.
  
      The files are expected to follow the structure:
          path/to/dataset/[training_videos|testing_videos]/video_filename.avi
          path/to/ground_truth/mask_filename.mat
  
      Args:
          root (Path): Path to dataset
          gt_dir (Path): Path to the ground truth
          split (Split | str | None = None, optional): Dataset split (ie., either train or test). Defaults to None.
  
      Example:
          The following example shows how to get testing samples from Avenue dataset:
  
          >>> root = Path('./avenue')
          >>> gt_dir = Path('./avenue/masks')
          >>> samples = make_avenue_dataset(path, gt_dir, split='test')
          >>> samples.head()
             root     folder         image_path                      mask_path                   split
          0  ./avenue testing_videos ./avenue/training_videos/01.avi ./avenue/masks/01_label.mat test
          1  ./avenue testing_videos ./avenue/training_videos/02.avi ./avenue/masks/01_label.mat test
          ...
  
      Returns:
          DataFrame: an output dataframe containing samples for the requested split (ie., train or test)
      """
  
      samples_list = [
          (str(root),) + filename.parts[-2:]
          for filename in Path(root).glob("**/*.avi")
      ]
      samples = DataFrame(
          samples_list, columns=["root", "folder", "image_path"]
      )
  
      samples.loc[samples.folder == "testing_videos", "mask_path"] = (
          samples.image_path.str.split(".").str[0].str.lstrip("0")
          + "_label.mat"
      )
      samples.loc[samples.folder == "testing_videos", "mask_path"] = (
          str(gt_dir) + "/testing_label_mask/" + samples.mask_path
      )
      samples.loc[samples.folder == "training_videos", "mask_path"] = ""
  
      samples["image_path"] = (
          samples.root + "/" + samples.folder + "/" + samples.image_path
      )
  
      samples.loc[
          samples.folder == "training_videos", "split"
      ] = "train"
      samples.loc[samples.folder == "testing_videos", "split"] = "test"
  
      if split:
          samples = samples[samples.split == split]
          samples = samples.reset_index(drop=True)
  
      return samples
  
imports: from __future__ import annotations
  import logging
  import math
  from pathlib import Path
  from shutil import move
  from typing import Callable
  import albumentations
  import cv2
  import numpy
  import scipy.io
  from pandas import DataFrame
  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
  from anomalib.data.utils.video import ClipsIndexer
label_desc: Use image node_id 1 for calling a global function with example usage: make_avenue_dataset(root, gt_dir, split) and returns: samples