code: def make_shanghaitech_dataset(
      root: Path, scene: int, split: Split | str | None = None
  ) -> DataFrame:
      """Create ShanghaiTech 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
          scene (int): Index of the dataset scene (category) in range [1, 13]
          split (Split | str | None, optional): Dataset split (ie., either train or test). Defaults to None.
  
      Example:
          The following example shows how to get testing samples from ShanghaiTech dataset:
  
          >>> root = Path('./shanghaiTech')
          >>> scene = 1
          >>> samples = make_avenue_dataset(path, scene, split='test')
          >>> samples.head()
              root            image_path                          split   mask_path
          0	shanghaitech	shanghaitech/testing/frames/01_0014	test	shanghaitech/testing/test_pixel_mask/01_0014.npy
          1	shanghaitech	shanghaitech/testing/frames/01_0015	test	shanghaitech/testing/test_pixel_mask/01_0015.npy
          ...
  
      Returns:
          DataFrame: an output dataframe containing samples for the requested split (ie., train or test)
      """
      scene_prefix = str(scene).zfill(2)
  
      # get paths to training videos
      train_root = Path(root) / "training/converted_videos"
      train_list = [
          (str(train_root),) + filename.parts[-2:]
          for filename in train_root.glob(f"{scene_prefix}_*.avi")
      ]
      train_samples = DataFrame(
          train_list, columns=["root", "folder", "image_path"]
      )
      train_samples["split"] = "train"
  
      # get paths to testing folders
      test_root = Path(root) / "testing/frames"
      test_folders = [
          filename
          for filename in sorted(test_root.glob(f"{scene_prefix}_*"))
          if filename.is_dir()
      ]
      test_folders = [
          folder
          for folder in test_folders
          if len(list(folder.glob("*.jpg"))) > 0
      ]
      test_list = [
          (str(test_root),) + folder.parts[-2:]
          for folder in test_folders
      ]
      test_samples = DataFrame(
          test_list, columns=["root", "folder", "image_path"]
      )
      test_samples["split"] = "test"
  
      samples = pd.concat(
          [train_samples, test_samples], ignore_index=True
      )
  
      gt_root = Path(root) / "testing/test_pixel_mask"
      samples["mask_path"] = ""
      samples.loc[samples.root == str(test_root), "mask_path"] = (
          str(gt_root)
          + "/"
          + samples.image_path.str.split(".").str[0]
          + ".npy"
      )
  
      samples["image_path"] = samples.root + "/" + samples.image_path
  
      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
  import albumentations
  import numpy
  import pandas
  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, convert_video
label_desc: Use image node_id 1 for calling a global function with example usage: make_shanghaitech_dataset(root, scene, split) and returns: samples