code: def parse_dataset_as_name(name: str) -> str:
      """
      Constructs a valid prefix-name from a provided file path.
  
      Args:
          name: str path to some valid data/manifest file or a python object that
              will be used as a name for the data loader (via str() cast).
  
      Returns:
          str prefix used to identify uniquely this data/manifest file.
      """
      if (
          os.path.exists(str(name))
          or os.path.isdir(str(name))
          or is_datastore_path(str(name))
      ):
          name = Path(name).stem
      else:
          name = str(name)
  
      # cleanup name
      name = name.replace("-", "_")
  
      if "manifest" in name:
          name = name.replace("manifest", "")
  
      if "dataset" in name:
          name = name.replace("dataset", "")
  
      # Test if the manifes/dataset name was simply `manifest.yaml` or `dataset.yaml`: Invalid names.
      if name == "":
          raise ValueError(
              "Provided dataset / manifest filename was `manifest.json` or `dataset.json`.\n"
              "Such a name is invalid, since multiple datasets/manifests can share the same name,\n"
              "thereby overriding their results during logging. Please pick a more discriptive filename \n"
              "for the provided dataset / manifest file."
          )
  
      if "_" != name[-1]:
          name = name + "_"
  
      return name
  
imports: import copy
  import importlib
  import os
  from dataclasses import dataclass, is_dataclass
  from enum import Enum
  from functools import lru_cache
  from pathlib import Path
  from typing import List, Optional, Tuple, Union
  import wrapt
  from nemo.utils import AppState, logging
  from nemo.utils.data_utils import resolve_cache_dir
  from nemo.utils.data_utils import is_datastore_path
label_desc: Use image node_id 2 for calling a global function with example usage: parse_dataset_as_name(name) and returns: name