code: def _parseq(
      arch: str,
      pretrained: bool,
      backbone_fn: Callable[[bool], nn.Module],
      layer: str,
      ignore_keys: Optional[List[str]] = None,
      **kwargs: Any,
  ) -> PARSeq:
      # Patch the config
      _cfg = deepcopy(default_cfgs[arch])
      _cfg["vocab"] = kwargs.get("vocab", _cfg["vocab"])
      _cfg["input_shape"] = kwargs.get(
          "input_shape", _cfg["input_shape"]
      )
      patch_size = kwargs.get("patch_size", (4, 8))
  
      kwargs["vocab"] = _cfg["vocab"]
      kwargs["input_shape"] = _cfg["input_shape"]
  
      # Feature extractor
      feat_extractor = IntermediateLayerGetter(
          # NOTE: we don't use a pretrained backbone for non-rectangular patches to avoid the pos embed mismatch
          backbone_fn(False, input_shape=_cfg["input_shape"], patch_size=patch_size),  # type: ignore[call-arg]
          {layer: "features"},
      )
  
      kwargs.pop("patch_size", None)
      kwargs.pop("pretrained_backbone", None)
  
      # Build the model
      model = PARSeq(feat_extractor, 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 _cfg["vocab"] != default_cfgs[arch]["vocab"]
              else None
          )
          load_pretrained_params(
              model, default_cfgs[arch]["url"], ignore_keys=_ignore_keys
          )
  
      return model
  
imports: import math
  from copy import deepcopy
  from itertools import permutations
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from torch import nn
  from torch.nn import functional
  from torchvision.models._utils import IntermediateLayerGetter
  from doctr.datasets import VOCABS
  from doctr.models.modules.transformer import MultiHeadAttention, PositionwiseFeedForward
  from ...classification import vit_s
  from ...utils.pytorch import _bf16_to_float32, load_pretrained_params
  from .base import _PARSeq, _PARSeqPostProcessor
label_desc: Use image node_id 1 for calling a global function with example usage: _parseq(arch, pretrained, backbone_fn, layer, ignore_keys) and returns: model