code: def conv_layer(
      ni: int,
      nf: int,
      ks: int = 3,
      stride: int = 1,
      padding: int = None,
      bias: bool = None,
      is_1d: bool = False,
      norm_type="Batch",
      use_activ: bool = True,
      leaky: float = None,
      transpose: bool = False,
      init=None,
      self_attention: bool = False,
  ):
      "Create a sequence of convolutional (`ni` to `nf`), ReLU (if `use_activ`) and batchnorm (if `bn`) layers."
      if padding is None:
          padding = (ks - 1) // 2 if not transpose else 0
      bn = norm_type in ("Batch", "BatchZero")
      if bias is None:
          bias = not bn
      conv_func = (
          nn.Conv2DTranspose
          if transpose
          else nn.Conv1d
          if is_1d
          else nn.Conv2D
      )
  
      conv = conv_func(
          ni,
          nf,
          kernel_size=ks,
          bias_attr=bias,
          stride=stride,
          padding=padding,
      )
      if norm_type == "Weight":
          conv = nn.utils.weight_norm(conv)
      elif norm_type == "Spectral":
          conv = U.Spectralnorm(conv)
  
      layers = [conv]
      if use_activ:
          layers.append(relu(True, leaky=leaky))
      if bn:
          layers.append((nn.BatchNorm if is_1d else nn.BatchNorm)(nf))
      if self_attention:
          layers.append(SelfAttention(nf))
      return nn.Sequential(*layers)
  
imports: import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddle.vision.models import resnet101
  from .None import utils
label_desc: Use image node_id 4 for calling a global function with example usage: conv_layer(ni, nf, ks, stride, padding, bias, is_1d, norm_type, use_activ, leaky, transpose, init, _attention) and returns: nn