code: def make_folder3d_dataset(
      normal_dir: str | Path,
      root: str | Path | None = None,
      abnormal_dir: str | Path | None = None,
      normal_test_dir: str | Path | None = None,
      mask_dir: str | Path | None = None,
      normal_depth_dir: str | Path | None = None,
      abnormal_depth_dir: str | Path | None = None,
      normal_test_depth_dir: str | Path | None = None,
      split: str | Split | None = None,
      extensions: tuple[str, ...] | None = None,
  ) -> DataFrame:
      """Make Folder Dataset.
  
      Args:
          normal_dir (str | Path): Path to the directory containing normal images.
          root (str | Path | None): Path to the root directory of the dataset.
          abnormal_dir (str | Path | None, optional): Path to the directory containing abnormal images.
          normal_test_dir (str | Path | None, optional): Path to the directory containing
              normal images for the test dataset. Normal test images will be a split of `normal_dir`
              if `None`. Defaults to None.
          mask_dir (str | Path | None, optional): Path to the directory containing
              the mask annotations. Defaults to None.
          normal_depth_dir (str | Path | None, optional): Path to the directory containing
              normal depth images for the test dataset. Normal test depth images will be a split of `normal_dir`
          abnormal_depth_dir (str | Path | None, optional): Path to the directory containing
              abnormal depth images for the test dataset.
          normal_test_depth_dir (str | Path | None, optional): Path to the directory containing
              normal depth images for the test dataset. Normal test images will be a split of `normal_dir`
              if `None`. Defaults to None.
          split (str | Split | None, optional): Dataset split (ie., Split.FULL, Split.TRAIN or Split.TEST).
              Defaults to None.
          extensions (tuple[str, ...] | None, optional): Type of the image extensions to read from the
              directory.
  
      Returns:
          DataFrame: an output dataframe containing samples for the requested split (ie., train or test)
      """
      normal_dir = _resolve_path(normal_dir, root)
      abnormal_dir = (
          _resolve_path(abnormal_dir, root)
          if abnormal_dir is not None
          else None
      )
      normal_test_dir = (
          _resolve_path(normal_test_dir, root)
          if normal_test_dir is not None
          else None
      )
      mask_dir = (
          _resolve_path(mask_dir, root)
          if mask_dir is not None
          else None
      )
      normal_depth_dir = (
          _resolve_path(normal_depth_dir, root)
          if normal_depth_dir is not None
          else None
      )
      abnormal_depth_dir = (
          _resolve_path(abnormal_depth_dir, root)
          if abnormal_depth_dir is not None
          else None
      )
      normal_test_depth_dir = (
          _resolve_path(normal_test_depth_dir, root)
          if normal_test_depth_dir is not None
          else None
      )
  
      assert (
          normal_dir.is_dir()
      ), "A folder location must be provided in normal_dir."
  
      filenames = []
      labels = []
      dirs = {DirType.NORMAL: normal_dir}
  
      if abnormal_dir:
          dirs = {**dirs, **{DirType.ABNORMAL: abnormal_dir}}
  
      if normal_test_dir:
          dirs = {**dirs, **{DirType.NORMAL_TEST: normal_test_dir}}
  
      if normal_depth_dir:
          dirs = {**dirs, **{DirType.NORMAL_DEPTH: normal_depth_dir}}
  
      if abnormal_depth_dir:
          dirs = {
              **dirs,
              **{DirType.ABNORMAL_DEPTH: abnormal_depth_dir},
          }
  
      if normal_test_depth_dir:
          dirs = {
              **dirs,
              **{DirType.NORMAL_TEST_DEPTH: normal_test_depth_dir},
          }
  
      if mask_dir:
          dirs = {**dirs, **{DirType.MASK: mask_dir}}
  
      for dir_type, path in dirs.items():
          filename, label = _prepare_files_labels(
              path, dir_type, extensions
          )
          filenames += filename
          labels += label
  
      samples = DataFrame({"image_path": filenames, "label": labels})
      samples = samples.sort_values(by="image_path", ignore_index=True)
  
      # Create label index for normal (0) and abnormal (1) images.
      samples.loc[
          (samples.label == DirType.NORMAL)
          | (samples.label == DirType.NORMAL_TEST),
          "label_index",
      ] = LabelName.NORMAL
      samples.loc[
          (samples.label == DirType.ABNORMAL), "label_index"
      ] = LabelName.ABNORMAL
      samples.label_index = samples.label_index.astype("Int64")
  
      # If a path to mask is provided, add it to the sample dataframe.
      if normal_depth_dir is not None:
          samples.loc[
              samples.label == DirType.NORMAL, "depth_path"
          ] = samples.loc[
              samples.label == DirType.NORMAL_DEPTH
          ].image_path.values
          samples.loc[
              samples.label == DirType.ABNORMAL, "depth_path"
          ] = samples.loc[
              samples.label == DirType.ABNORMAL_DEPTH
          ].image_path.values
  
          if normal_test_dir is not None:
              samples.loc[
                  samples.label == DirType.NORMAL_TEST, "depth_path"
              ] = samples.loc[
                  samples.label == DirType.NORMAL_TEST_DEPTH
              ].image_path.values
  
          # make sure every rgb image has a corresponding depth image and that the file exists
          assert (
              samples.loc[samples.label_index == LabelName.ABNORMAL]
              .apply(
                  lambda x: Path(x.image_path).stem
                  in Path(x.depth_path).stem,
                  axis=1,
              )
              .all()
          ), "Mismatch between anomalous images and depth images. Make sure the mask files in 'xyz' \
              folder follow the same naming convention as the anomalous images in the dataset \
              (e.g. image: '000.png', depth: '000.tiff')."
  
          assert samples.depth_path.apply(
              lambda x: Path(x).exists() if not isna(x) else True
          ).all(), "missing depth image files"
  
          samples = samples.astype({"depth_path": "str"})
  
      # If a path to mask is provided, add it to the sample dataframe.
      if mask_dir is not None and abnormal_dir is not None:
          samples.loc[
              samples.label == DirType.ABNORMAL, "mask_path"
          ] = samples.loc[
              samples.label == DirType.MASK
          ].image_path.values
          samples["mask_path"].fillna("", inplace=True)
          samples = samples.astype({"mask_path": "str"})
  
          # make sure all the files exist
          assert samples.mask_path.apply(
              lambda x: Path(x).exists() if x != "" else True
          ).all(), f"missing mask files, mask_dir={mask_dir}"
      else:
          samples["mask_path"] = ""
  
      # remove all the rows with temporal image samples that have already been assigned
      samples = samples.loc[
          (samples.label == DirType.NORMAL)
          | (samples.label == DirType.ABNORMAL)
          | (samples.label == DirType.NORMAL_TEST)
      ]
  
      # Ensure the pathlib objects are converted to str.
      # This is because torch dataloader doesn't like pathlib.
      samples = samples.astype({"image_path": "str"})
  
      # Create train/test split.
      # By default, all the normal samples are assigned as train.
      #   and all the abnormal samples are test.
      samples.loc[
          (samples.label == DirType.NORMAL), "split"
      ] = Split.TRAIN
      samples.loc[
          (samples.label == DirType.ABNORMAL)
          | (samples.label == DirType.NORMAL_TEST),
          "split",
      ] = Split.TEST
  
      # Get the data frame for the split.
      if split:
          samples = samples[samples.split == split]
          samples = samples.reset_index(drop=True)
  
      return samples
  
file_path: anomalib/src/anomalib/data/folder_3d.py
imports: from __future__ import annotations
  from pathlib import Path
  import albumentations
  from pandas import DataFrame, isna
  from anomalib.data.base import AnomalibDataModule, AnomalibDepthDataset
  from anomalib.data.task_type import TaskType
  from anomalib.data.utils import DirType, InputNormalizationMethod, LabelName, Split, TestSplitMode, ValSplitMode, get_transforms
  from anomalib.data.utils.path import _prepare_files_labels, _resolve_path
label_desc: Use image node_id 1 for calling a global function with example usage: make_folder3d_dataset(normal_dir, root, abnormal_dir, normal_test_dir, mask_dir, normal_depth_dir, abnormal_depth_dir, normal_test_depth_dir, split, extensions) and returns: samples