text: import torch
  import torch.nn as nn
  
  def add_conv(in_ch, out_ch, ksize, stride):
      """
      Add a conv2d / batchnorm / leaky ReLU block.
      Args:
          in_ch (int): number of input channels of the convolution layer.
          out_ch (int): number of output channels of the convolution layer.
          ksize (int): kernel size of the convolution layer.
          stride (int): stride of the convolution layer.
      Returns:
          stage (Sequential) : Sequential layers composing a convolution block.
      """
      stage = nn.Sequential()
      pad = (ksize - 1) // 2
      stage.add_module('conv', nn.Conv2d(in_channels=in_ch,
                                         out_channels=out_ch, kernel_size=ksize, stride=stride,
                                         padding=pad, bias=False))
      stage.add_module('batch_norm', nn.BatchNorm2d(out_ch))
      stage.add_module('leaky', nn.LeakyReLU(0.1))
      return stage
  
  
  class resblock(nn.Module):
      """
      Sequential residual blocks each of which consists of \
      two convolution layers.
      Args:
          ch (int): number of input and output channels.
          nblocks (int): number of residual blocks.
          shortcut (bool): if True, residual tensor addition is enabled.
      """
      def __init__(self, ch, nblocks=1, shortcut=True):
  
          super().__init__()
          self.shortcut = shortcut
          self.module_list = nn.ModuleList()
          for i in range(nblocks):
              resblock_one = nn.ModuleList()
              resblock_one.append(add_conv(ch, ch//2, 1, 1))
              resblock_one.append(add_conv(ch//2, ch, 3, 1))
              self.module_list.append(resblock_one)
  
      def forward(self, x):
          for module in self.module_list:
              h = x
              for res in module:
                  h = res(h)
              x = x + h if self.shortcut else h
          return x