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 compare_or_false(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 collections.abc
  from collections.abc import Sequence
  import decimal
  import inspect
  import pprint
  import re
  from typing import Any, TypeVar, Union
  import jax
label_desc: Use image node_id 2 for calling a global function with example usage: auto_repr(cls) and returns: single_line, str