code: def echo(fn, write=sys.stdout.write):
      """Echo calls to a function.
  
      Returns a decorated version of the input function which "echoes" calls
      made to it by writing out the function's name and the arguments it was
      called with.
      """
      import functools
  
      # Unpack function's arg count, arg names, arg defaults
      code = fn.__code__
      argcount = code.co_argcount
      argnames = code.co_varnames[:argcount]
      fn_defaults = fn.__defaults__ or list()
      argdefs = dict(
          list(zip(argnames[-len(fn_defaults) :], fn_defaults))
      )
  
      @functools.wraps(fn)
      def wrapped(*v, **k):
          # Collect function arguments by chaining together positional,
          # defaulted, extra positional and keyword arguments.
          positional = list(
              map(format_arg_value, list(zip(argnames, v)))
          )
          defaulted = [
              format_arg_value((a, argdefs[a]))
              for a in argnames[len(v) :]
              if a not in k
          ]
          nameless = list(map(repr, v[argcount:]))
          keyword = list(map(format_arg_value, list(k.items())))
          args = positional + defaulted + nameless + keyword
          write("%s(%s)\n" % (name(fn), ", ".join(args)))
          return fn(*v, **k)
  
      return wrapped
  
file_path: wandb/wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/echo.py
imports: import inspect
  import sys
label_desc: Use image node_id 7 for calling a global function with example usage: echo(fn, write) and returns: wrapped, fn