code: def _gaussian_filter(
      img: tf.Tensor,
      kernel_size: Union[int, Iterable[int]],
      sigma: float,
      mode: Optional[str] = None,
      pad_value: Optional[int] = 0,
  ):
      """Apply Gaussian filter to image.
      Adapted from: https://github.com/tensorflow/addons/blob/master/tensorflow_addons/image/filters.py
  
      Args:
      ----
          img: image to filter of shape (N, H, W, C)
          kernel_size: kernel size of the filter
          sigma: standard deviation of the Gaussian filter
          mode: padding mode, one of "CONSTANT", "REFLECT", "SYMMETRIC"
          pad_value: value to pad the image with
  
      Returns:
      -------
          A tensor of shape (N, H, W, C)
      """
      ksize = tf.convert_to_tensor(
          tf.broadcast_to(kernel_size, [2]), dtype=tf.int32
      )
      sigma = tf.convert_to_tensor(
          tf.broadcast_to(sigma, [2]), dtype=img.dtype
      )
      assert mode in (
          "CONSTANT",
          "REFLECT",
          "SYMMETRIC",
      ), "mode should be one of 'CONSTANT', 'REFLECT', 'SYMMETRIC'"
      mode = "CONSTANT" if mode is None else str.upper(mode)
      constant_values = (
          tf.zeros([], dtype=img.dtype)
          if pad_value is None
          else tf.convert_to_tensor(pad_value, dtype=img.dtype)
      )
  
      def kernel1d(ksize: tf.Tensor, sigma: tf.Tensor, dtype: tf.DType):
          x = tf.range(ksize, dtype=dtype)
          x = x - tf.cast(tf.math.floordiv(ksize, 2), dtype=dtype)
          x = x + tf.where(
              tf.math.equal(tf.math.mod(ksize, 2), 0),
              tf.cast(0.5, dtype),
              0,
          )
          g = tf.math.exp(
              -(tf.math.pow(x, 2) / (2 * tf.math.pow(sigma, 2)))
          )
          g = g / tf.reduce_sum(g)
          return g
  
      def kernel2d(ksize: tf.Tensor, sigma: tf.Tensor, dtype: tf.DType):
          kernel_x = kernel1d(ksize[0], sigma[0], dtype)
          kernel_y = kernel1d(ksize[1], sigma[1], dtype)
          return tf.matmul(
              tf.expand_dims(kernel_x, axis=-1),
              tf.transpose(tf.expand_dims(kernel_y, axis=-1)),
          )
  
      g = kernel2d(ksize, sigma, img.dtype)
      # Pad the image
      height, width = ksize[0], ksize[1]
      paddings = [
          [0, 0],
          [(height - 1) // 2, height - 1 - (height - 1) // 2],
          [(width - 1) // 2, width - 1 - (width - 1) // 2],
          [0, 0],
      ]
      img = tf.pad(
          img, paddings, mode=mode, constant_values=constant_values
      )
  
      channel = tf.shape(img)[-1]
      shape = tf.concat(
          [ksize, tf.constant([1, 1], ksize.dtype)], axis=0
      )
      g = tf.reshape(g, shape)
      shape = tf.concat(
          [ksize, [channel], tf.constant([1], ksize.dtype)], axis=0
      )
      g = tf.broadcast_to(g, shape)
      return tf.nn.depthwise_conv2d(
          img, g, [1, 1, 1, 1], padding="VALID", data_format="NHWC"
      )
  
file_path: doctr/doctr/transforms/functional/tensorflow.py
imports: import math
  import random
  from copy import deepcopy
  from typing import Iterable, Optional, Tuple, Union
  import numpy
  import tensorflow
  from doctr.utils.geometry import compute_expanded_shape, rotate_abs_geoms
  from .base import create_shadow_mask, crop_boxes
label_desc: Use image node_id 5 for calling a global function with example usage: _gaussian_filter(img, kernel_size, sigma, mode, pad_value) and returns: tf, g, tf