code: def _append_med(arr, pad_amt, num, axis=-1):
      """
      Append `pad_amt` median values along `axis`.
  
      Parameters
      ----------
      arr : ndarray
          Input array of arbitrary shape.
      pad_amt : int
          Amount of padding to append.
      num : int
          Depth into `arr` along `axis` to calculate median.
          Range: [1, `arr.shape[axis]`] or None (entire axis)
      axis : int
          Axis along which to pad `arr`.
  
      Returns
      -------
      padarr : ndarray
          Output array, with `pad_amt` values appended along `axis`. The
          appended region is the median of the final `num` values along `axis`.
  
      """
      if pad_amt == 0:
          return arr
  
      # Equivalent to edge padding for single value, so do that instead
      if num == 1:
          return _append_edge(arr, pad_amt, axis)
  
      # Use entire array if `num` is too large
      if num is not None:
          if num >= arr.shape[axis]:
              num = None
  
      # Slice a chunk from the edge to calculate stats on
      if num is not None:
          med_slice = _slice_last(arr.shape, num, axis=axis)
      else:
          med_slice = tuple(slice(None) for x in arr.shape)
  
      # Extract slice, calculate median
      med_chunk = np.median(arr[med_slice], axis=axis, keepdims=True)
      _round_ifneeded(med_chunk, arr.dtype)
  
      # Concatenate `arr` with `med_chunk`, extended along `axis` by `pad_amt`
      return _do_append(arr, med_chunk.repeat(pad_amt, axis), axis=axis)
  
imports: from __future__ import division, absolute_import, print_function
  import numpy
  from numpy.core.overrides import array_function_dispatch
label_desc: Use image node_id 19 for calling a global function with example usage: _append_med(arr, pad_amt, num, axis) and returns: _do_append, arr, _append_edge