code: def max_pool3d(
      x: np.ndarray,
      kernel: Union[int, Tuple[int, ...]],
      strides: Union[int, Tuple[int, ...]],
      padding: Union[str, int, Tuple[int], List[Tuple[int, int]]],
      /,
      *,
      data_format: str = "NDHWC",
      dilation: Union[int, Tuple[int, ...]] = 1,
      ceil_mode: bool = False,
      out: Optional[np.ndarray] = None,
  ) -> np.ndarray:
      dims = 3
      kernel, strides, padding, dilation = _validate_max_pool_params(
          kernel,
          strides,
          padding,
          dilation,
          ceil_mode,
          dims,
          data_format,
      )
  
      if data_format == "NCDHW":
          x = np.transpose(x, (0, 2, 3, 4, 1))
          kernel = (
              [kernel[i] for i in [0, 2, 3, 4, 1]]
              if len(kernel) == (dims + 2)
              else kernel
          )
          strides = (
              [strides[i] for i in [0, 2, 3, 4, 1]]
              if len(strides) == (dims + 2)
              else strides
          )
          padding = (
              [padding[i] for i in [0, 2, 3, 4, 1]]
              if isinstance(padding, list)
              and len(padding) == (dims + 2)
              else padding
          )
  
      x, kernel, strides, depth_pooling = _determine_depth_max_pooling(
          x, kernel, strides, dims, data_format="channel_last"
      )
  
      x_shape = x.shape[1:4]
      filters = np.ones((list(kernel)), dtype=x.dtype)
      if not depth_pooling:
          for j in range(dims):
              if dilation[j] > 1:
                  filters = _add_dilations(
                      filters, dilation[j], axis=j, values=0
                  )
          kernel = list(filters.shape)
          pad_list = padding
          if isinstance(padding, str):
              pad_d = _handle_padding(
                  x_shape[0], strides[0], kernel[0], padding
              )
              pad_h = _handle_padding(
                  x_shape[1], strides[1], kernel[1], padding
              )
              pad_w = _handle_padding(
                  x_shape[2], strides[2], kernel[2], padding
              )
              pad_list = [
                  (pad_d // 2, pad_d - pad_d // 2),
                  (pad_h // 2, pad_h - pad_h // 2),
                  (pad_w // 2, pad_w - pad_w // 2),
              ]
          pad_list = list(pad_list)
          if ceil_mode:
              for i in range(dims):
                  pad_list[i] = _padding_ceil_mode(
                      x_shape[i], kernel[i], pad_list[i], strides[i]
                  )
  
          x = np.pad(
              x,
              [
                  (0, 0),
                  *pad_list,
                  (0, 0),
              ],
              "constant",
              constant_values=-math.inf,
          )
      else:
          if isinstance(padding, list) and any(
              item != 0 for sublist in padding for item in sublist
          ):
              raise NotImplementedError(
                  "Nonzero explicit padding is not supported for depthwise max pooling"
              )
  
      x_shape = x.shape
      new_d = (x_shape[1] - kernel[0]) // strides[0] + 1
      new_h = (x_shape[2] - kernel[1]) // strides[1] + 1
      new_w = (x_shape[3] - kernel[2]) // strides[2] + 1
      new_shape = (
          [x_shape[0], new_d, new_h, new_w]
          + list(kernel)
          + [x_shape[-1]]
      )
      new_strides = (
          x.strides[0],
          x.strides[1] * strides[0],
          x.strides[2] * strides[1],
          x.strides[3] * strides[2],
          x.strides[1],
          x.strides[2],
          x.strides[3],
          x.strides[4],
      )
      # B x OD x OH x OW x KD x KH x KW x I
      sub_matrices = np.lib.stride_tricks.as_strided(
          x, new_shape, new_strides, writeable=False
      )
  
      # B x OD x OH x OW x KD x KH x KW x I
      sub_matrices = np.where(
          filters.reshape([1] * 4 + list(kernel) + [1]),
          sub_matrices,
          -math.inf,
      )
  
      # B x OD x OH x OW x O
      res = sub_matrices.max(axis=(4, 5, 6))
  
      if depth_pooling:
          res = np.transpose(res, (0, 2, 3, 4, 1))
      if data_format == "NCDHW":
          return np.transpose(res, (0, 4, 1, 2, 3))
      return res
  
imports: import math
  import numpy
  from typing import Optional, Union, Tuple, List, Literal, Sequence, Callable
  import ivy
  from ivy.functional.ivy.layers import _handle_padding, _get_num_padded_values, _validate_max_pool_params, _depth_max_pooling_helper
  from ivy.functional.backends.numpy.layers import _add_dilations
  from ivy.functional.ivy.experimental.layers import _padding_ceil_mode
  from ivy.func_wrapper import with_supported_dtypes
  from ivy.func_wrapper import with_unsupported_dtypes
  from .None import backend_version
label_desc: Use image node_id 4 for calling a global function with example usage: max_pool3d() and returns: res, np