code: def resnet_stage(
      in_channels: int, out_channels: int, num_blocks: int, stride: int
  ) -> List[nn.Module]:
      """Build a ResNet stage"""
      _layers: List[nn.Module] = []
  
      in_chan = in_channels
      s = stride
      for _ in range(num_blocks):
          downsample = None
          if in_chan != out_channels:
              downsample = nn.Sequential(
                  *conv_sequence_pt(
                      in_chan,
                      out_channels,
                      False,
                      True,
                      kernel_size=1,
                      stride=s,
                  )
              )
  
          _layers.append(
              BasicBlock(
                  in_chan, out_channels, stride=s, downsample=downsample
              )
          )
          in_chan = out_channels
          # Only the first block can have stride != 1
          s = 1
  
      return _layers
  
imports: from copy import deepcopy
  from typing import Any, Callable, Dict, List, Optional, Tuple
  from torch import nn
  from torchvision.models.resnet import BasicBlock
  from torchvision.models.resnet import ResNet
  from torchvision.models.resnet import resnet18
  from torchvision.models.resnet import resnet34
  from torchvision.models.resnet import resnet50
  from doctr.datasets import VOCABS
  from ...utils import conv_sequence_pt, load_pretrained_params
label_desc: Use image node_id 1 for calling a global function with example usage: resnet_stage(in_channels, out_channels, num_blocks, stride) and returns: _layers