code: def array_function_dispatch(
      dispatcher, module=None, verify=True, docs_from_dispatcher=False
  ):
      """Decorator for adding dispatch with the __array_function__ protocol.
  
      See NEP-18 for example usage.
  
      Parameters
      ----------
      dispatcher : callable
          Function that when called like ``dispatcher(*args, **kwargs)`` with
          arguments from the NumPy function call returns an iterable of
          array-like arguments to check for ``__array_function__``.
      module : str, optional
          __module__ attribute to set on new function, e.g., ``module='numpy'``.
          By default, module is copied from the decorated function.
      verify : bool, optional
          If True, verify the that the signature of the dispatcher and decorated
          function signatures match exactly: all required and optional arguments
          should appear in order with the same names, but the default values for
          all optional arguments should be ``None``. Only disable verification
          if the dispatcher's signature needs to deviate for some particular
          reason, e.g., because the function has a signature like
          ``func(*args, **kwargs)``.
      docs_from_dispatcher : bool, optional
          If True, copy docs from the dispatcher function onto the dispatched
          function, rather than from the implementation. This is useful for
          functions defined in C, which otherwise don't have docstrings.
  
      Returns
      -------
      Function suitable for decorating the implementation of a NumPy function.
      """
  
      if not ENABLE_ARRAY_FUNCTION:
          # __array_function__ requires an explicit opt-in for now
          def decorator(implementation):
              if module is not None:
                  implementation.__module__ = module
              if docs_from_dispatcher:
                  add_docstring(implementation, dispatcher.__doc__)
              return implementation
  
          return decorator
  
      def decorator(implementation):
          if verify:
              verify_matching_signatures(implementation, dispatcher)
  
          if docs_from_dispatcher:
              add_docstring(implementation, dispatcher.__doc__)
  
          @functools.wraps(implementation)
          def public_api(*args, **kwargs):
              relevant_args = dispatcher(*args, **kwargs)
              return implement_array_function(
                  implementation,
                  public_api,
                  relevant_args,
                  args,
                  kwargs,
              )
  
          if module is not None:
              public_api.__module__ = module
  
          # TODO: remove this when we drop Python 2 support (functools.wraps
          # adds __wrapped__ automatically in later versions)
          public_api.__wrapped__ = implementation
  
          return public_api
  
      return decorator
  
file_path: catboost/contrib/python/numpy/py2/numpy/core/overrides.py
imports: import collections
  import functools
  import os
  from numpy.core._multiarray_umath import add_docstring, implement_array_function, _get_implementing_args
  from numpy.compat._inspect import getargspec
label_desc: Use image node_id 3 for calling a global function with example usage: array_function_dispatch(dispatcher, module, verify, docs_from_dispatcher) and returns: decorator, decorator, public_api, implementation, implement_array_function