code: def auto_repr(cls: Type[Any], *args, **kwargs) -> str:
      """Derives a `__repr__` from constructor arguments of a given class.
  
          >>> class Foo:
          ...   def __init__(self, x=None, y=42):
          ...      pass
          ...
  
          >>> auto_repr(Foo, "x")
          "Foo(x='x')"
  
          >>> auto_repr(Foo, "x", y=21)
          "Foo(x='x', y=21)"
  
          >>> auto_repr(Foo, None, 42)
          Foo()
  
      Args:
        cls: a class to derive `__repr__` for.
        *args: positional arguments.
        **kwargs: keyword arguments.
  
      Returns:
        A string representing a call equivalent to `cls(*args, **kwargs)`.
      """
      argspec = inspect.getfullargspec(cls.__init__)
      arg_names = argspec.args
      # Keep used positionals minus self.
      arg_names = arg_names[1 : (len(args) + 1)]
      # Keep used kwargs in the order they appear in argspec.
      arg_names.extend(n for n in argspec.args if n in kwargs)
      arg_values = inspect.getcallargs(
          cls.__init__, None, *args, **kwargs
      )  # pylint: disable=deprecated-method
  
      # Extract default parameter values.
      defaults = argspec.defaults or ()
      defaults = dict(zip(argspec.args[-len(defaults) :], defaults))
      is_default = lambda n, v: (
          n in defaults and safe_compare(v, defaults[n])
      )
  
      names_and_values = [
          (name + "=", arg_values[name])
          for name in arg_names
          if not is_default(name, arg_values[name])
      ]
      # Add varargs.
      names_and_values.extend(
          ("", arg) for arg in args[len(argspec.args) - 1 :]
      )
      # Add varkwargs.
      names_and_values.extend(
          (name + "=", kwargs[name])
          for name in kwargs
          if name not in argspec.args
      )
  
      single_line = cls.__name__ + "({})".format(
          ", ".join(
              name + repr(value) for name, value in names_and_values
          )
      )
      if len(single_line) <= 80:
          return single_line
      else:
          return "{}(\n{},\n)".format(
              cls.__name__,
              indent(
                  4,
                  ",\n".join(
                      fancy_repr(n, v) for n, v in names_and_values
                  ),
              ),
          )
  
imports: import abc
  import functools
  import inspect
  import os
  import pprint
  import sys
  from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Type, TypeVar
  from sonnet.src import once
  from sonnet.src import types
  from sonnet.src import utils
  import tensorflow
label_desc: Use image node_id 3 for calling a global function with example usage: auto_repr(cls) and returns: single_line, str