code: def array_wrap(arg_name, _not_specified=object()):
      """
      Decorator for functions working on array_likes that ensures the type of
      output matches that of the input, delegating to the input's __array_wrap__.
  
      Parameters
      ----------
      arg_name : str
  
          The name of the array_like arg to the wrapped function. Should be the
          first positional parameter to the wrapped function.
  
      """
  
      def dec(f):
          @wraps(f)
          def _wrapit(*args, **kwds):
              obj = kwds.get(arg_name, _not_specified)
              if obj is _not_specified:
                  obj = args[0]
  
              try:
                  wrap = obj.__array_wrap__
              except AttributeError:
                  wrap = None
              result = f(*args, **kwds)
              if wrap:
                  if not isinstance(result, np.ndarray):
                      result = np.asarray(result)
                  result = wrap(result)
              return result
  
          return _wrapit
  
      return dec
  
imports: from __future__ import division
  from functools import wraps
  import pandas
  import numpy
  from scipy import stats
  from six import iteritems
  from empyrical.utils import nanmean, nanstd, nanmin
label_desc: Use image node_id 5 for calling a global function with example usage: array_wrap(arg_name, _not_specified) and returns: dec, _wrapit, result