code: def upfirdn_2d(
      x,
      k,
      upx=1,
      upy=1,
      downx=1,
      downy=1,
      padx0=0,
      padx1=0,
      pady0=0,
      pady1=0,
      impl="cuda",
  ):
      r"""Pad, upsample, FIR filter, and downsample a batch of 2D images.
  
      Accepts a batch of 2D images of the shape `[majorDim, inH, inW, minorDim]`
      and performs the following operations for each image, batched across
      `majorDim` and `minorDim`:
  
      1. Pad the image with zeros by the specified number of pixels on each side
         (`padx0`, `padx1`, `pady0`, `pady1`). Specifying a negative value
         corresponds to cropping the image.
  
      2. Upsample the image by inserting the zeros after each pixel (`upx`, `upy`).
  
      3. Convolve the image with the specified 2D FIR filter (`k`), shrinking the
         image so that the footprint of all output pixels lies within the input image.
  
      4. Downsample the image by throwing away pixels (`downx`, `downy`).
  
      This sequence of operations bears close resemblance to scipy.signal.upfirdn().
      The fused op is considerably more efficient than performing the same calculation
      using standard TensorFlow ops. It supports gradients of arbitrary order.
  
      Args:
          x:      Input tensor of the shape `[majorDim, inH, inW, minorDim]`.
          k:      2D FIR filter of the shape `[firH, firW]`.
          upx:    Integer upsampling factor along the X-axis (default: 1).
          upy:    Integer upsampling factor along the Y-axis (default: 1).
          downx:  Integer downsampling factor along the X-axis (default: 1).
          downy:  Integer downsampling factor along the Y-axis (default: 1).
          padx0:  Number of pixels to pad on the left side (default: 0).
          padx1:  Number of pixels to pad on the right side (default: 0).
          pady0:  Number of pixels to pad on the top side (default: 0).
          pady1:  Number of pixels to pad on the bottom side (default: 0).
          impl:   Name of the implementation to use. Can be `"ref"` or `"cuda"` (default).
  
      Returns:
          Tensor of the shape `[majorDim, outH, outW, minorDim]`, and same datatype as `x`.
      """
  
      impl_dict = {
          "ref": _upfirdn_2d_ref,
          "cuda": _upfirdn_2d_cuda,
      }
      return impl_dict[impl](
          x=x,
          k=k,
          upx=upx,
          upy=upy,
          downx=downx,
          downy=downy,
          padx0=padx0,
          padx1=padx1,
          pady0=pady0,
          pady1=pady1,
      )
  
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 2 for calling a global function with example usage: upfirdn_2d(x, k, upx, upy, downx, downy, padx0, padx1, pady0, pady1, impl) and returns: impl_dict