code: def main(
      anno_path,
      cache_name="uuid_filenames",
      ref_cache=None,
      ref_ext=".mp4",
      flatten=False,
      no_ext_hash=False,
  ):
      # pylint: disable=line-too-long， missing-function-docstring
      dataset = GluonCVMotionDataset(anno_path)
  
      id_mapping = {}
      cache_dir = Path(dataset.cache_root_path) / cache_name
  
      new_path_set = set()
      samples = dataset.samples
      for sample_id, sample in tqdm.tqdm(samples, mininterval=1):
          if ref_cache:
              ref_filepath = sample.get_cache_file(ref_cache, ref_ext)
          else:
              ref_filepath = sample.data_path
  
          orig_cache_filepath = Path(
              sample.get_cache_file(
                  cache_name, Path(ref_filepath).suffix
              )
          )
          orig_suffix = orig_cache_filepath.suffix
          orig_cache_rel_filepath = orig_cache_filepath.relative_to(
              cache_dir
          )
          if no_ext_hash:
              orig_cache_rel_filepath = (
                  orig_cache_rel_filepath.with_suffix("")
              )
          orig_filename = orig_cache_rel_filepath.name
  
          if flatten:
              hashed_filepath = hash_path(
                  orig_cache_rel_filepath, suffix_len=len(orig_suffix)
              )
              uuid_rel_filepath = hashed_filepath + orig_suffix
          else:
              hashed_filename = hash_path(
                  orig_filename, suffix_len=len(orig_suffix)
              )
              uuid_rel_filepath = orig_cache_rel_filepath.with_name(
                  hashed_filename + orig_suffix
              )
          uuid_filepath = cache_dir / uuid_rel_filepath
          if uuid_rel_filepath in new_path_set:
              existing_id = [
                  id
                  for id, p in id_mapping.items()
                  if p == str(uuid_rel_filepath)
              ]
              _log.error(
                  "Unexpected filename collision with: {} , \
                         existing id: {} , new sample id: {}".format(
                      uuid_rel_filepath, existing_id, sample_id
                  )
              )
              continue
          new_path_set.add(uuid_rel_filepath)
          id_mapping[sample_id] = str(uuid_rel_filepath)
          os.makedirs(uuid_filepath.parent, exist_ok=True)
          if not os.path.exists(uuid_filepath):
              os.symlink(ref_filepath, uuid_filepath)
  
      save_json(id_mapping, cache_dir / "id_mapping.json")
  
file_path: gluon-cv/gluoncv/torch/data/gluoncv_motion_dataset/ingestion/filename_sanitizer.py
imports: import logging
  import os
  import hashlib
  import re
  from pathlib import Path
  import tqdm
  from ..dataset import GluonCVMotionDataset
  from ..utils.serialization_utils import save_json
label_desc: Use image node_id 2 for calling a global function with example usage: main(anno_path, cache_name, ref_cache, ref_ext, flatten, no_ext_hash) without return types