code: def filter_2d(x, k, gain=1, data_format="NCHW", impl="cuda"):
      r"""Filter a batch of 2D images with the given FIR filter.
  
      Accepts a batch of 2D images of the shape `[N, C, H, W]` or `[N, H, W, C]`
      and filters each image with the given filter. The filter is normalized so that
      if the input pixels are constant, they will be scaled by the specified `gain`.
      Pixels outside the image are assumed to be zero.
  
      Args:
          x:            Input tensor of the shape `[N, C, H, W]` or `[N, H, W, C]`.
          k:            FIR filter of the shape `[firH, firW]` or `[firN]` (separable).
          gain:         Scaling factor for signal magnitude (default: 1.0).
          data_format:  `'NCHW'` or `'NHWC'` (default: `'NCHW'`).
          impl:         Name of the implementation to use. Can be `"ref"` or `"cuda"` (default).
  
      Returns:
          Tensor of the same shape and datatype as `x`.
      """
  
      k = _setup_kernel(k) * gain
      p = k.shape[0] - 1
      return _simple_upfirdn_2d(
          x,
          k,
          pad0=(p + 1) // 2,
          pad1=p // 2,
          data_format=data_format,
          impl=impl,
      )
  
file_path: insightface/reconstruction/ostec/external/stylegan2/dnnlib/tflib/ops/upfirdn_2d.py
imports: import os
  import numpy
  import tensorflow
  from ..None import custom_ops
label_desc: Use image node_id 5 for calling a global function with example usage: filter_2d(x, k, gain, data_format, impl) and returns: _simple_upfirdn_2d