code: def _predictor(
      arch: Any,
      pretrained: bool,
      assume_straight_pages: bool = True,
      **kwargs: Any,
  ) -> DetectionPredictor:
      if isinstance(arch, str):
          if arch not in ARCHS:
              raise ValueError(f"unknown architecture '{arch}'")
  
          _model = detection.__dict__[arch](
              pretrained=pretrained,
              pretrained_backbone=kwargs.get(
                  "pretrained_backbone", True
              ),
              assume_straight_pages=assume_straight_pages,
          )
      else:
          if not isinstance(arch, (detection.DBNet, detection.LinkNet)):
              raise ValueError(f"unknown architecture: {type(arch)}")
  
          _model = arch
          _model.assume_straight_pages = assume_straight_pages
  
      kwargs.pop("pretrained_backbone", None)
  
      kwargs["mean"] = kwargs.get("mean", _model.cfg["mean"])
      kwargs["std"] = kwargs.get("std", _model.cfg["std"])
      kwargs["batch_size"] = kwargs.get("batch_size", 1)
      predictor = DetectionPredictor(
          PreProcessor(
              _model.cfg["input_shape"][:-1]
              if is_tf_available()
              else _model.cfg["input_shape"][1:],
              **kwargs,
          ),
          _model,
      )
      return predictor
  
imports: from typing import Any, List
  from doctr.file_utils import is_tf_available, is_torch_available
  from ..None import detection
  from ..preprocessor import PreProcessor
  from .predictor import DetectionPredictor
label_desc: Use image node_id 1 for calling a global function with example usage: _predictor(arch, pretrained, assume_straight_pages) and returns: predictor