code: def _pad_sym(arr, pad_amt, method, axis=-1):
      """
      Pad `axis` of `arr` by symmetry.
  
      Parameters
      ----------
      arr : ndarray
          Input array of arbitrary shape.
      pad_amt : tuple of ints, length 2
          Padding to (prepend, append) along `axis`.
      method : str
          Controls method of symmetry; options are 'even' or 'odd'.
      axis : int
          Axis along which to pad `arr`.
  
      Returns
      -------
      padarr : ndarray
          Output array, with `pad_amt[0]` values prepended and `pad_amt[1]`
          values appended along `axis`. Both regions are padded with symmetric
          values from the original array.
  
      Notes
      -----
      This algorithm DOES pad with repetition, i.e. the edges are repeated.
      For padding without repeated edges, use `mode='reflect'`.
  
      The modes 'reflect', 'symmetric', and 'wrap' must be padded with a
      single function, lest the indexing tricks in non-integer multiples of the
      original shape would violate repetition in the final iteration.
  
      """
      # Implicit booleanness to test for zero (or None) in any scalar type
      if pad_amt[0] == 0 and pad_amt[1] == 0:
          return arr
  
      ##########################################################################
      # Prepended region
  
      # Slice off a reverse indexed chunk from near edge to pad `arr` before
      sym_slice = _slice_first(arr.shape, pad_amt[0], axis=axis)
      rev_idx = _slice_at_axis(
          arr.shape, slice(None, None, -1), axis=axis
      )
      sym_chunk1 = arr[sym_slice][rev_idx]
  
      # Memory/computationally more expensive, only do this if `method='odd'`
      if "odd" in method and pad_amt[0] > 0:
          edge_slice1 = _slice_first(arr.shape, 1, axis=axis)
          edge_chunk = arr[edge_slice1]
          sym_chunk1 = 2 * edge_chunk - sym_chunk1
          del edge_chunk
  
      ##########################################################################
      # Appended region
  
      # Slice off a reverse indexed chunk from far edge to pad `arr` after
      sym_slice = _slice_last(arr.shape, pad_amt[1], axis=axis)
      sym_chunk2 = arr[sym_slice][rev_idx]
  
      if "odd" in method:
          edge_slice2 = _slice_last(arr.shape, 1, axis=axis)
          edge_chunk = arr[edge_slice2]
          sym_chunk2 = 2 * edge_chunk - sym_chunk2
          del edge_chunk
  
      # Concatenate `arr` with both chunks, extending along `axis`
      return np.concatenate((sym_chunk1, arr, sym_chunk2), 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 23 for calling a global function with example usage: _pad_sym(arr, pad_amt, method, axis) and returns: np, arr