code: def _get_stats(padded, axis, width_pair, length_pair, stat_func):
      """Calculates a statistic for an empty-padded array along a given axis.
  
      Args:
        padded(cupy.ndarray): Empty-padded array.
        axis(int): Dimension in which the statistic is calculated.
        width_pair((int, int)): Pair of widths that mark the pad area on both
            sides in the given dimension.
        length_pair(2-element sequence of None or int): Gives the number of
            values in valid area from each side that is taken into account when
            calculating the statistic. If None the entire valid area in `padded`
            is considered.
        stat_func(function): Function to compute statistic. The expected
            signature is
            ``stat_func(x: ndarray, axis: int, keepdims: bool) -> ndarray``.
      """
      # Calculate indices of the edges of the area with original values
      left_index = width_pair[0]
      right_index = padded.shape[axis] - width_pair[1]
      # as well as its length
      max_length = right_index - left_index
  
      # Limit stat_lengths to max_length
      left_length, right_length = length_pair
      if left_length is None or max_length < left_length:
          left_length = max_length
      if right_length is None or max_length < right_length:
          right_length = max_length
  
      # Calculate statistic for the left side
      left_slice = _slice_at_axis(
          slice(left_index, left_index + left_length), axis
      )
      left_chunk = padded[left_slice]
      left_stat = stat_func(left_chunk, axis=axis, keepdims=True)
      _round_if_needed(left_stat, padded.dtype)
  
      if left_length == right_length == max_length:
          # return early as right_stat must be identical to left_stat
          return left_stat, left_stat
  
      # Calculate statistic for the right side
      right_slice = _slice_at_axis(
          slice(right_index - right_length, right_index), axis
      )
      right_chunk = padded[right_slice]
      right_stat = stat_func(right_chunk, axis=axis, keepdims=True)
      _round_if_needed(right_stat, padded.dtype)
      return left_stat, right_stat
  
file_path: cupy/cupy/_padding/pad.py
imports: import numbers
  import numpy
  import cupy
label_desc: Use image node_id 8 for calling a global function with example usage: _get_stats(padded, axis, width_pair, length_pair, stat_func) and returns: left_stat,  right_stat, left_stat,  left_stat