code: def conv_block(
      in_nc,
      out_nc,
      kernel_size,
      stride=1,
      dilation=1,
      groups=1,
      bias=True,
      pad_type="zero",
      norm_type=None,
      act_type="relu",
      mode="CNA",
      convtype="Conv2D",
      spectral_norm=False,
  ):
      """Conv layer with padding, normalization, activation"""
      assert mode in ["CNA", "NAC", "CNAC"], f"Wrong conv mode [{mode}]"
      padding = get_valid_padding(kernel_size, dilation)
      p = (
          pad(pad_type, padding)
          if pad_type and pad_type != "zero"
          else None
      )
      padding = padding if pad_type == "zero" else 0
  
      if convtype == "PartialConv2D":
          from torchvision.ops import (
              PartialConv2d,
          )  # this is definitely not going to work, but PartialConv2d doesn't work anyway and this shuts up static analyzer
  
          c = PartialConv2d(
              in_nc,
              out_nc,
              kernel_size=kernel_size,
              stride=stride,
              padding=padding,
              dilation=dilation,
              bias=bias,
              groups=groups,
          )
      elif convtype == "DeformConv2D":
          from torchvision.ops import DeformConv2d  # not tested
  
          c = DeformConv2d(
              in_nc,
              out_nc,
              kernel_size=kernel_size,
              stride=stride,
              padding=padding,
              dilation=dilation,
              bias=bias,
              groups=groups,
          )
      elif convtype == "Conv3D":
          c = nn.Conv3d(
              in_nc,
              out_nc,
              kernel_size=kernel_size,
              stride=stride,
              padding=padding,
              dilation=dilation,
              bias=bias,
              groups=groups,
          )
      else:
          c = nn.Conv2d(
              in_nc,
              out_nc,
              kernel_size=kernel_size,
              stride=stride,
              padding=padding,
              dilation=dilation,
              bias=bias,
              groups=groups,
          )
  
      if spectral_norm:
          c = nn.utils.spectral_norm(c)
  
      a = act(act_type) if act_type else None
      if "CNA" in mode:
          n = norm(norm_type, out_nc) if norm_type else None
          return sequential(p, c, n, a)
      elif mode == "NAC":
          if norm_type is None and act_type is not None:
              a = act(act_type, inplace=False)
          n = norm(norm_type, in_nc) if norm_type else None
          return sequential(n, a, p, c)
  
imports: from collections import OrderedDict
  import math
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 11 for calling a global function with example usage: conv_block(in_nc, out_nc, kernel_size, stride, dilation, groups, bias, pad_type, norm_type, act_type, mode, convtype, spectral_norm) and returns: sequential, sequential