code: def _pad_arrs_to_max_length(
      arrs, pad_val, use_shared_mem, dtype, round_to=None
  ):
      """Inner Implementation of the Pad batchify
      Parameters
      ----------
      arrs : list
      pad_val : number
      use_shared_mem : bool, default False
      round_to : int
  
      Returns
      -------
      ret : NDArray
      """
      _arr = _np if is_np_array() else nd
      _arr_cls = _np.ndarray if is_np_array() else nd.NDArray
      if isinstance(arrs[0], _arr_cls):
          dtype = arrs[0].dtype if dtype is None else dtype
          arrs = [arr.asnumpy() for arr in arrs]
      elif not isinstance(arrs[0], np.ndarray):
          arrs = [np.asarray(ele) for ele in arrs]
          dtype = arrs[0][0].dtype if dtype is None else dtype
      else:
          dtype = arrs[0].dtype if dtype is None else dtype
  
      ret_shape = list(arrs[0].shape)
      for pad_axis in range(len(ret_shape)):
          curr_lengths = [ele.shape[pad_axis] for ele in arrs]
          max_size = max(curr_lengths)
          if round_to is not None:
              max_size = round_to * math.ceil(max_size / round_to)
          ret_shape[pad_axis] = max_size
      ret_shape = (len(arrs),) + tuple(ret_shape)
  
      ret = np.full(shape=ret_shape, fill_value=pad_val, dtype=dtype)
  
      for i, arr in enumerate(arrs):
          if arr.shape == ret_shape[1:]:
              ret[i] = arr
          else:
              slices = [slice(None) for _ in range(arr.ndim)]
              for pad_axis in range(arr.ndim):
                  slices[pad_axis] = slice(0, arr.shape[pad_axis])
                  assert slices[pad_axis].start != slices[pad_axis].stop
              slices = [slice(i, i + 1)] + slices
              ret[tuple(slices)] = arr
  
      device = Device("cpu_shared", 0) if use_shared_mem else cpu()
      ret = _arr.array(ret, ctx=device, dtype=dtype)
  
      return ret
  
imports: import math
  import warnings
  import numpy
  from ...device import Device, cpu
  from ...None import ndarray
  from ...None import numpy
  from ...util import is_np_array
label_desc: Use image node_id 1 for calling a global function with example usage: _pad_arrs_to_max_length(arrs, pad_val, use_shared_mem, dtype, round_to) and returns: ret