code: def modify_paths(object, relative=True, basedir=None):
      """Convert paths in data structure to either full paths or relative paths
  
      Supports combinations of lists, dicts, tuples, strs
  
      Parameters
      ----------
  
      relative : boolean indicating whether paths should be set relative to the
                 current directory
      basedir : default os.getcwd()
                what base directory to use as default
      """
      if not basedir:
          basedir = os.getcwd()
      if isinstance(object, dict):
          out = {}
          for key, val in sorted(object.items()):
              if isdefined(val):
                  out[key] = modify_paths(
                      val, relative=relative, basedir=basedir
                  )
      elif isinstance(object, (list, tuple)):
          out = []
          for val in object:
              if isdefined(val):
                  out.append(
                      modify_paths(
                          val, relative=relative, basedir=basedir
                      )
                  )
          if isinstance(object, tuple):
              out = tuple(out)
      else:
          if isdefined(object):
              if isinstance(object, (str, bytes)) and os.path.isfile(
                  object
              ):
                  if relative:
                      if config.getboolean(
                          "execution", "use_relative_paths"
                      ):
                          out = relpath(object, start=basedir)
                      else:
                          out = object
                  else:
                      out = os.path.abspath(
                          os.path.join(basedir, object)
                      )
                  if not os.path.exists(out):
                      raise OSError("File %s not found" % out)
              else:
                  out = object
          else:
              raise TypeError(f"Object {object} is undefined")
      return out
  
imports: import os
  import sys
  import pickle
  from collections import defaultdict
  import re
  from copy import deepcopy
  from glob import glob
  from pathlib import Path
  from traceback import format_exception
  from hashlib import sha1
  from functools import reduce
  import numpy
  from ...None import logging, config
  from ...utils.filemanip import indirectory, relpath, fname_presuffix, ensure_list, get_related_files, save_json, savepkl, loadpkl, write_rst_header, write_rst_dict, write_rst_list
  from ...utils.misc import str2bool
  from ...utils.functions import create_function_from_source
  from ...interfaces.base.traits_extension import rebase_path_traits, resolve_path_traits, OutputMultiPath, isdefined, Undefined
  from ...interfaces.base.support import Bunch, InterfaceResult
  from ...interfaces.base import CommandLine
  from ...interfaces.utility import IdentityInterface
  from ...utils.provenance import ProvStore, pm, nipype_ns, get_id
  from inspect import signature
label_desc: Use image node_id 11 for calling a global function with example usage: modify_paths(object, relative, basedir) and returns: out