code: def _vgg(
      arch: str,
      pretrained: bool,
      tv_arch: str,
      num_rect_pools: int = 3,
      ignore_keys: Optional[List[str]] = None,
      **kwargs: Any,
  ) -> tv_vgg.VGG:
      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 = tv_vgg.__dict__[tv_arch](**kwargs, weights=None)
      # List the MaxPool2d
      pool_idcs = [
          idx
          for idx, m in enumerate(model.features)
          if isinstance(m, nn.MaxPool2d)
      ]
      # Replace their kernel with rectangular ones
      for idx in pool_idcs[-num_rect_pools:]:
          model.features[idx] = nn.MaxPool2d((2, 1))
      # Patch average pool & classification head
      model.avgpool = nn.AdaptiveAvgPool2d((1, 1))
      model.classifier = nn.Linear(512, kwargs["num_classes"])
      # 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
          )
  
      model.cfg = _cfg
  
      return model
  
file_path: doctr/doctr/models/classification/vgg/pytorch.py
imports: from copy import deepcopy
  from typing import Any, Dict, List, Optional
  from torch import nn
  from torchvision.models import vgg
  from doctr.datasets import VOCABS
  from ...utils import load_pretrained_params
label_desc: Use image node_id 1 for calling a global function with example usage: _vgg(arch, pretrained, tv_arch, num_rect_pools, ignore_keys) and returns: model