class_docstr: Implements a ResNet-31 architecture from `"Show, Attend and Read:A Simple and Strong Baseline for Irregular
  Text Recognition" <https://arxiv.org/pdf/1811.00751.pdf>`_.
  
  Args:
  ----
      num_blocks: number of resnet block in each stage
      output_channels: number of channels in each stage
      stage_conv: whether to add a conv_sequence after each stage
      stage_pooling: pooling to add after each stage (if None, no pooling)
      origin_stem: whether to use the orginal ResNet stem or ResNet-31's
      stem_channels: number of output channels of the stem convolutions
      attn_module: attention module to use in each stage
      include_top: whether the classifier head should be instantiated
      num_classes: number of output classes
class_docstr_tok: ["Implements","a","ResNet-31","architecture","from","`","``","Show",",","Attend","and","Read",":","A","Simple","and","Strong","Baseline","for","Irregular","Text","Recognition","''","<","https",":","\/\/arxiv.org\/pdf\/1811.00751.pdf",">","`","_",".","Args",":","--","--","num_blocks",":","number","of","resnet","block","in","each","stage","output_channels",":","number","of","channels","in","each","stage","stage_conv",":","whether","to","add","a","conv_sequence","after","each","stage","stage_pooling",":","pooling","to","add","after","each","stage","(","if","None",",","no","pooling",")","origin_stem",":","whether","to","use","the","orginal","ResNet","stem","or","ResNet-31's","stem_channels",":","number","of","output","channels","of","the","stem","convolutions","attn_module",":","attention","module","to","use","in","each","stage","include_top",":","whether","the","classifier","head","should","be","instantiated","num_classes",":","number","of","output","classes"]
code: def __init__(
      self,
      num_blocks: List[int],
      output_channels: List[int],
      stage_stride: List[int],
      stage_conv: List[bool],
      stage_pooling: List[Optional[Tuple[int, int]]],
      origin_stem: bool = True,
      stem_channels: int = 64,
      attn_module: Optional[Callable[[int], nn.Module]] = None,
      include_top: bool = True,
      num_classes: int = 1000,
      cfg: Optional[Dict[str, Any]] = None,
  ) -> None:
      _layers: List[nn.Module]
      if origin_stem:
          _layers = [
              *conv_sequence_pt(
                  3,
                  stem_channels,
                  True,
                  True,
                  kernel_size=7,
                  padding=3,
                  stride=2,
              ),
              nn.MaxPool2d(kernel_size=3, stride=2, padding=1),
          ]
      else:
          _layers = [
              *conv_sequence_pt(
                  3,
                  stem_channels // 2,
                  True,
                  True,
                  kernel_size=3,
                  padding=1,
              ),
              *conv_sequence_pt(
                  stem_channels // 2,
                  stem_channels,
                  True,
                  True,
                  kernel_size=3,
                  padding=1,
              ),
              nn.MaxPool2d(2),
          ]
      in_chans = [stem_channels] + output_channels[:-1]
      for n_blocks, in_chan, out_chan, stride, conv, pool in zip(
          num_blocks,
          in_chans,
          output_channels,
          stage_stride,
          stage_conv,
          stage_pooling,
      ):
          _stage = resnet_stage(in_chan, out_chan, n_blocks, stride)
          if attn_module is not None:
              _stage.append(attn_module(out_chan))
          if conv:
              _stage.extend(
                  conv_sequence_pt(
                      out_chan,
                      out_chan,
                      True,
                      True,
                      kernel_size=3,
                      padding=1,
                  )
              )
          if pool is not None:
              _stage.append(nn.MaxPool2d(pool))
          _layers.append(nn.Sequential(*_stage))
  
      if include_top:
          _layers.extend(
              [
                  nn.AdaptiveAvgPool2d(1),
                  nn.Flatten(1),
                  nn.Linear(
                      output_channels[-1], num_classes, bias=True
                  ),
              ]
          )
  
      super().__init__(*_layers)
      self.cfg = cfg
  
      for m in self.modules():
          if isinstance(m, nn.Conv2d):
              nn.init.kaiming_normal_(
                  m.weight, mode="fan_out", nonlinearity="relu"
              )
          elif isinstance(m, (nn.BatchNorm2d, nn.GroupNorm)):
              nn.init.constant_(m.weight, 1)
              nn.init.constant_(m.bias, 0)
  
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 to create a new ResNet object from inherited base classes: nn with example: obj = ResNet(num_blocks, output_channels, stage_stride, stage_conv, stage_pooling, origin_stem, stem_channels, attn_module, include_top, num_classes, cfg)