code: def format_filename(
      filename,
      relroot=USE_CWD,
      *,
      fixroot=True,
      normalize=True,
      _badprefix=f"..{os.path.sep}",
  ):
      """Return a consistent relative-path representation of the filename."""
      orig = filename
      if normalize:
          filename = os.path.normpath(filename)
      if relroot is None:
          # Otherwise leave it as-is.
          return filename
      elif relroot is USE_CWD:
          # Make it relative to CWD.
          filename = os.path.relpath(filename)
      else:
          # Make it relative to "relroot".
          if fixroot:
              relroot = os.path.abspath(relroot)
          elif not relroot:
              raise ValueError("missing relroot")
          filename = os.path.relpath(filename, relroot)
      if filename.startswith(_badprefix):
          raise ValueError(
              f"bad filename {orig!r} (resolves beyond relative root"
          )
      return filename
  
imports: import fnmatch
  import glob
  import os
  import os.path
  import shutil
  import stat
  from .iterutil import iter_many
label_desc: Use image node_id 5 for calling a global function with example usage: format_filename(filename, relroot) and returns: filename, filename