docstr: Fused `Conv2d()` followed by `downsample_2d()`.
  
  Args:
  Padding is performed only once at the beginning, not between the operations. The fused op is considerably more
  efficient than performing the same calculation using standard TensorFlow ops. It supports gradients of arbitrary:
  order.
      x: Input tensor of the shape `[N, C, H, W]` or `[N, H, W, C]`. w: Weight tensor of the shape `[filterH,
      filterW, inChannels, outChannels]`. Grouped convolution can be performed by `inChannels = x.shape[0] //
      numGroups`. k: FIR filter of the shape `[firH, firW]` or `[firN]` (separable). The default is `[1] *
      factor`, which corresponds to average pooling. factor: Integer downsampling factor (default: 2). gain:
      Scaling factor for signal magnitude (default: 1.0).
  
  Returns:
      Tensor of the shape `[N, C, H // factor, W // factor]` or `[N, H // factor, W // factor, C]`, and same
      datatype as `x`.
docstr_tok: ["Fused","`","Conv2d","(",")","`","followed","by","`","downsample_2d","(",")","`",".","Args",":","Padding","is","performed","only","once","at","the","beginning",",","not","between","the","operations",".","The","fused","op","is","considerably","more","efficient","than","performing","the","same","calculation","using","standard","TensorFlow","ops",".","It","supports","gradients","of","arbitrary",":","order",".","x",":","Input","tensor","of","the","shape","`","[","N",",","C",",","H",",","W","]","`","or","`","[","N",",","H",",","W",",","C","]","`",".","w",":","Weight","tensor","of","the","shape","`","[","filterH",",","filterW",",","inChannels",",","outChannels","]","`",".","Grouped","convolution","can","be","performed","by","`","inChannels","=","x.shape","[","0","]","\/\/","numGroups","`",".","k",":","FIR","filter","of","the","shape","`","[","firH",",","firW","]","`","or","`","[","firN","]","`","(","separable",")",".","The","default","is","`","[","1","]","*","factor","`",",","which","corresponds","to","average","pooling",".","factor",":","Integer","downsampling","factor","(","default",":","2",")",".","gain",":","Scaling","factor","for","signal","magnitude","(","default",":","1.0",")",".","Returns",":","Tensor","of","the","shape","`","[","N",",","C",",","H","\/\/","factor",",","W","\/\/","factor","]","`","or","`","[","N",",","H","\/\/","factor",",","W","\/\/","factor",",","C","]","`",",","and","same","datatype","as","`","x","`","."]
code: def _downsample_2d(self, x, w=None, k=None, factor=2, gain=1):
      """Fused `Conv2d()` followed by `downsample_2d()`.
  
      Args:
      Padding is performed only once at the beginning, not between the operations. The fused op is considerably more
      efficient than performing the same calculation using standard TensorFlow ops. It supports gradients of arbitrary:
      order.
          x: Input tensor of the shape `[N, C, H, W]` or `[N, H, W, C]`. w: Weight tensor of the shape `[filterH,
          filterW, inChannels, outChannels]`. Grouped convolution can be performed by `inChannels = x.shape[0] //
          numGroups`. k: FIR filter of the shape `[firH, firW]` or `[firN]` (separable). The default is `[1] *
          factor`, which corresponds to average pooling. factor: Integer downsampling factor (default: 2). gain:
          Scaling factor for signal magnitude (default: 1.0).
  
      Returns:
          Tensor of the shape `[N, C, H // factor, W // factor]` or `[N, H // factor, W // factor, C]`, and same
          datatype as `x`.
      """
  
      assert isinstance(factor, int) and factor >= 1
      if k is None:
          k = [1] * factor
  
      # setup kernel
      k = np.asarray(k, dtype=np.float32)
      if k.ndim == 1:
          k = np.outer(k, k)
      k /= np.sum(k)
  
      k = k * gain
  
      if self.use_conv:
          _, _, convH, convW = w.shape
          p = (k.shape[0] - factor) + (convW - 1)
          s = [factor, factor]
          x = upfirdn2d_native(
              x, paddle.to_tensor(k), pad=((p + 1) // 2, p // 2)
          )
          x = F.conv2d(x, w, stride=s, padding=0)
      else:
          p = k.shape[0] - factor
          x = upfirdn2d_native(
              x,
              paddle.to_tensor(k),
              down=factor,
              pad=((p + 1) // 2, p // 2),
          )
  
      return x
  
imports: from functools import partial
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
label_desc: Use image node_id 2 for calling the FirDownsample2D obj's underlying member method code with example usage: obj._downsample_2d(x, w, k, factor, gain) and returns: x