code: def _sar(
      arch: str,
      pretrained: bool,
      backbone_fn: Callable[[bool], nn.Module],
      layer: str,
      pretrained_backbone: bool = True,
      ignore_keys: Optional[List[str]] = None,
      **kwargs: Any,
  ) -> SAR:
      pretrained_backbone = pretrained_backbone and not pretrained
  
      # 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"]
      )
  
      # Feature extractor
      feat_extractor = IntermediateLayerGetter(
          backbone_fn(pretrained_backbone),
          {layer: "features"},
      )
      kwargs["vocab"] = _cfg["vocab"]
      kwargs["input_shape"] = _cfg["input_shape"]
  
      # Build the model
      model = SAR(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: from copy import deepcopy
  from typing import Any, Callable, Dict, List, Optional, Tuple
  import torch
  from torch import nn
  from torch.nn import functional
  from torchvision.models._utils import IntermediateLayerGetter
  from doctr.datasets import VOCABS
  from ...classification import resnet31
  from ...utils.pytorch import _bf16_to_float32, load_pretrained_params
  from ..core import RecognitionModel, RecognitionPostProcessor
label_desc: Use image node_id 1 for calling a global function with example usage: _sar(arch, pretrained, backbone_fn, layer, pretrained_backbone, ignore_keys) and returns: model