code: def _rebase_path(value, cwd):
      if isinstance(value, list):
          return [_rebase_path(v, cwd) for v in value]
  
      try:
          value = Path(value)
      except TypeError:
          pass
      else:
          try:
              value = value.relative_to(cwd)
          except ValueError:
              pass
      return value
  
imports: from collections.abc import Sequence
  from traits import __version__
  import traits.api
  from traits.api import TraitType, Unicode
  from traits.trait_base import _Undefined
  from pathlib import Path
  from ...utils.filemanip import path_resolve
label_desc: Use image node_id 4 for calling a global function with example usage: _rebase_path(value, cwd) and returns: value, unknown