code: def partial_return(func, k):
      """For a given function ``func`` which returns multiple outputs accessible by
      ``[]`` e.g. python list or dictionary, it construct a new function which only
      returns part of the output given in position `k` where key can be a key or
      other index.
  
      Parameters
      ----------
      func : callable
          A function which returns multiple output accessible by ``[]``
      k : `int` or `str`
          A key or index which is implemented by ``[]`` on output of the
          input function ``func``
  
      Returns
      -------
      result : callable
          A function which only returns part of what the input ``func`` returns given
          in position ``[k]``. In the case that the key does not exist or index is
          out of bound, it returns None.
      """
  
      def func_k(*args, **kwargs):
          res = func(*args, **kwargs)
          # If result is a dictionary we check if key `k` exist,
          # If so return the value for that key.
          if type(res) == dict:
              if k in res.keys():
                  return res[k]
          # This is for the non-dict case eg `list`, `pandas.Series`, `np.array`.
          # In this case we check if `k` is an `integer` and `res` has sufficient length.
          # If so, we return the k-th element.
          elif type(k) == int and len(res) > k:
              return res[k]
          # Otherwise it returns None.
          return None
  
      return func_k
  
file_path: greykite/greykite/detection/detector/ad_utils.py
imports: from functools import reduce
  import pandas
  from greykite.common.constants import ANOMALY_COL
  from greykite.common.constants import END_TIME_COL
  from greykite.common.constants import START_TIME_COL
  from greykite.common.constants import TIME_COL
  from greykite.common.features.outlier import ZScoreOutlierDetector
  from greykite.common.logging import LoggingLevelEnum
  from greykite.common.logging import log_message
  from greykite.detection.detector.constants import Z_SCORE_CUTOFF
label_desc: Use image node_id 1 for calling a global function with example usage: partial_return(func, k) and returns: func_k, None, res, res