code: def _pad(
      image: TensorLike,
      filter_shape: Union[List[int], Tuple[int]],
      mode: str = "CONSTANT",
      constant_values: TensorLike = 0,
  ) -> tf.Tensor:
      """Explicitly pad a 4-D image.
  
      Equivalent to the implicit padding method offered in `tf.nn.conv2d` and
      `tf.nn.depthwise_conv2d`, but supports non-zero, reflect and symmetric
      padding mode. For the even-sized filter, it pads one more value to the
      right or the bottom side.
  
      Args:
        image: A 4-D `Tensor` of shape `[batch_size, height, width, channels]`.
        filter_shape: A `tuple`/`list` of 2 integers, specifying the height
          and width of the 2-D filter.
        mode: A `string`, one of "REFLECT", "CONSTANT", or "SYMMETRIC".
          The type of padding algorithm to use, which is compatible with
          `mode` argument in `tf.pad`. For more details, please refer to
          https://www.tensorflow.org/api_docs/python/tf/pad.
        constant_values: A `scalar`, the pad value to use in "CONSTANT"
          padding mode.
      """
      if mode.upper() not in {"REFLECT", "CONSTANT", "SYMMETRIC"}:
          raise ValueError(
              'padding should be one of "REFLECT", "CONSTANT", or "SYMMETRIC".'
          )
      constant_values = tf.convert_to_tensor(
          constant_values, image.dtype
      )
      filter_height, filter_width = filter_shape
      pad_top = (filter_height - 1) // 2
      pad_bottom = filter_height - 1 - pad_top
      pad_left = (filter_width - 1) // 2
      pad_right = filter_width - 1 - pad_left
      paddings = [
          [0, 0],
          [pad_top, pad_bottom],
          [pad_left, pad_right],
          [0, 0],
      ]
      return tf.pad(
          image, paddings, mode=mode, constant_values=constant_values
      )
  
file_path: addons/tensorflow_addons/image/filters.py
imports: import tensorflow
  from tensorflow_addons.image import utils
  from tensorflow_addons.utils import keras_utils
  from tensorflow_addons.utils.types import TensorLike
  from typing import Optional, Union, List, Tuple, Iterable
label_desc: Use image node_id 1 for calling a global function with example usage: _pad(image, filter_shape, mode, constant_values) and returns: tf