code: def _get_stats(padded, axis, width_pair, length_pair, stat_func):
      left_index = width_pair[0]
      right_index = padded.shape[axis] - width_pair[1]
      max_length = right_index - left_index
      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
      left_slice = _slice_at_axis(
          slice(left_index, left_index + left_length), axis
      )
      left_chunk = padded[left_slice]
      left_chunk = (
          left_chunk.astype("float32")
          if ivy.is_int_dtype(left_chunk)
          else left_chunk
      )
      left_stat = stat_func(left_chunk, axis=axis, keepdims=True)
      left_stat = (
          ivy.round(left_stat).astype(padded.dtype)
          if ivy.is_int_dtype(padded)
          else left_stat
      )
      if left_length == right_length == max_length:
          return left_stat, left_stat
      right_slice = _slice_at_axis(
          slice(right_index - right_length, right_index), axis
      )
      right_chunk = padded[right_slice]
      right_chunk = (
          right_chunk.astype("float32")
          if ivy.is_int_dtype(right_chunk)
          else right_chunk
      )
      right_stat = stat_func(right_chunk, axis=axis, keepdims=True)
      right_stat = (
          ivy.round(right_stat).astype(padded.dtype)
          if ivy.is_int_dtype(padded)
          else right_stat
      )
      return left_stat, right_stat
  
imports: from typing import Optional, Union, Tuple, Iterable, Sequence, Callable, Any, Literal, List
  from numbers import Number
  from functools import partial
  import math
  import ivy
  from ivy.func_wrapper import handle_out_argument, handle_partial_mixed_function, to_native_arrays_and_back, inputs_to_native_shapes, handle_nestable, handle_array_like_without_promotion, handle_view, inputs_to_ivy_arrays, handle_array_function, handle_device, handle_backend_invalid
  from ivy.functional.ivy.general import _numel
  from ivy.utils.backend import current_backend
  from ivy.utils.exceptions import handle_exceptions
label_desc: Use image node_id 18 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