code: def _set_wrap_both(padded, axis, width_pair):
      left_pad, right_pad = width_pair
      period = padded.shape[axis] - right_pad - left_pad
      while left_pad > 0:
          right_slice = _slice_at_axis(
              slice(
                  -width_pair[1] - min(period, left_pad),
                  -width_pair[1] if width_pair[1] != 0 else None,
              ),
              axis,
          )
          right_chunk = padded[right_slice]
          if left_pad > period:
              pad_area = _slice_at_axis(
                  slice(left_pad - period, left_pad), axis
              )
              left_pad = left_pad - period
          else:
              pad_area = _slice_at_axis(slice(None, left_pad), axis)
              left_pad = 0
          padded[pad_area] = right_chunk
      while right_pad > 0:
          left_slice = _slice_at_axis(
              slice(
                  width_pair[0],
                  width_pair[0] + min(period, right_pad),
              ),
              axis,
          )
          left_chunk = padded[left_slice]
          if right_pad > period:
              pad_area = _slice_at_axis(
                  slice(-right_pad, -right_pad + period), axis
              )
              right_pad = right_pad - period
          else:
              pad_area = _slice_at_axis(slice(-right_pad, None), axis)
              right_pad = 0
          padded[pad_area] = left_chunk
      return padded
  
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 20 for calling a global function with example usage: _set_wrap_both(padded, axis, width_pair) and returns: padded