code: def _resnet(
      arch: str,
      pretrained: bool,
      num_blocks: List[int],
      output_channels: List[int],
      stage_stride: List[int],
      stage_conv: List[bool],
      stage_pooling: List[Optional[Tuple[int, int]]],
      ignore_keys: Optional[List[str]] = None,
      **kwargs: Any,
  ) -> ResNet:
      kwargs["num_classes"] = kwargs.get(
          "num_classes", len(default_cfgs[arch]["classes"])
      )
      kwargs["classes"] = kwargs.get(
          "classes", default_cfgs[arch]["classes"]
      )
  
      _cfg = deepcopy(default_cfgs[arch])
      _cfg["num_classes"] = kwargs["num_classes"]
      _cfg["classes"] = kwargs["classes"]
      kwargs.pop("classes")
  
      # Build the model
      model = ResNet(
          num_blocks,
          output_channels,
          stage_stride,
          stage_conv,
          stage_pooling,
          cfg=_cfg,
          **kwargs,
      )
      # Load pretrained parameters
      if pretrained:
          # The number of classes is not the same as the number of classes in the pretrained model =>
          # remove the last layer weights
          _ignore_keys = (
              ignore_keys
              if kwargs["num_classes"]
              != len(default_cfgs[arch]["classes"])
              else None
          )
          load_pretrained_params(
              model, default_cfgs[arch]["url"], ignore_keys=_ignore_keys
          )
  
      return model
  
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 2 for calling a global function with example usage: _resnet(arch, pretrained, num_blocks, output_channels, stage_stride, stage_conv, stage_pooling, ignore_keys) and returns: model