code: def max_pool3d(
      x: Union[tf.Tensor, tf.Variable],
      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[Union[tf.Tensor, tf.Variable]] = None,
  ) -> Union[tf.Tensor, tf.Variable]:
      dims = 3
      kernel, strides, padding, dilation = _validate_max_pool_params(
          kernel,
          strides,
          padding,
          dilation,
          ceil_mode,
          dims,
          data_format,
      )
  
      permuted_x = False
      if data_format == "NCDHW" and ivy.dev(x) == "cpu":
          x = tf.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
          )
          data_format = "NDHWC"
          permuted_x = True
  
      # determine depth pooling
      x, kernel, strides, depth_pooling = _determine_depth_max_pooling(
          x, kernel, strides, dims, data_format=data_format
      )
  
      if not depth_pooling:
          if ceil_mode:
              new_kernel = [
                  kernel[i] + (kernel[i] - 1) * (dilation[i] - 1)
                  for i in range(dims)
              ]
              if data_format == "NCDHW":
                  x_shape = x.shape[2:]
              else:
                  x_shape = x.shape[1:-1]
              if isinstance(padding, str):
                  pad_d = _handle_padding(
                      x_shape[0], strides[0], new_kernel[0], padding
                  )
                  pad_h = _handle_padding(
                      x_shape[1], strides[1], new_kernel[1], padding
                  )
                  pad_w = _handle_padding(
                      x_shape[2], strides[2], new_kernel[2], padding
                  )
                  padding = [
                      (pad_d // 2, pad_d - pad_d // 2),
                      (pad_h // 2, pad_h - pad_h // 2),
                      (pad_w // 2, pad_w - pad_w // 2),
                  ]
              for i in range(dims):
                  padding[i] = _padding_ceil_mode(
                      x_shape[i], new_kernel[i], padding[i], strides[i]
                  )
          if isinstance(padding, list):
              if any(
                  item != 0 for sublist in padding for item in sublist
              ):
                  if len(padding) < dims + 2:
                      if data_format == "NCDHW":
                          padding = [(0, 0), (0, 0), *padding]
                      else:
                          padding = [(0, 0), *padding, (0, 0)]
                  x = tf.pad(
                      x, padding, constant_values=tf.math.reduce_min(x)
                  )
              padding = "VALID"
      elif isinstance(padding, list):
          if any(item != 0 for sublist in padding for item in sublist):
              raise NotImplementedError(
                  "Nonzero explicit padding is not supported for depthwise max pooling"
              )
          else:
              padding = "VALID"
      res = tf.nn.pool(
          x,
          kernel,
          "MAX",
          strides,
          padding,
          dilations=dilation,
          data_format=data_format,
      )
  
      if depth_pooling:
          res = tf.transpose(res, (0, 2, 3, 4, 1))
      if permuted_x:
          return tf.transpose(res, (0, 4, 1, 2, 3))
      return res
  
imports: import math
  from typing import Union, Optional, Tuple, List, Literal, Sequence, Callable
  import tensorflow
  from ivy.func_wrapper import inputs_to_ivy_arrays, output_to_native_arrays, with_unsupported_dtypes, with_supported_dtypes, with_supported_device_and_dtypes
  from ..None import backend_version
  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.ivy.experimental.layers import _padding_ceil_mode, _get_size
label_desc: Use image node_id 4 for calling a global function with example usage: max_pool3d() and returns: res, tf