class_docstr: MMOCR Inferencer. It's a wrapper around three base task
  inferenecers: TextDetInferencer, TextRecInferencer and KIEInferencer,
  and it can be used to perform end-to-end OCR or KIE inference.
  
  Args:
      det (Optional[Union[ConfigType, str]]): Pretrained text detection
          algorithm. It's the path to the config file or the model name
          defined in metafile. Defaults to None.
      det_weights (Optional[str]): Path to the custom checkpoint file of
          the selected det model. If it is not specified and "det" is a model
          name of metafile, the weights will be loaded from metafile.
          Defaults to None.
      rec (Optional[Union[ConfigType, str]]): Pretrained text recognition
          algorithm. It's the path to the config file or the model name
          defined in metafile. Defaults to None.
      rec_weights (Optional[str]): Path to the custom checkpoint file of
          the selected rec model. If it is not specified and "rec" is a model
          name of metafile, the weights will be loaded from metafile.
          Defaults to None.
      kie (Optional[Union[ConfigType, str]]): Pretrained key information
          extraction algorithm. It's the path to the config file or the model
          name defined in metafile. Defaults to None.
      kie_weights (Optional[str]): Path to the custom checkpoint file of
          the selected kie model. If it is not specified and "kie" is a model
          name of metafile, the weights will be loaded from metafile.
          Defaults to None.
      device (Optional[str]): Device to run inference. If None, the available
          device will be automatically used. Defaults to None.
docstr: Call the inferencer.
  
  Args:
      inputs (InputsType): Inputs for the inferencer. It can be a path
          to image / image directory, or an array, or a list of these.
      batch_size (int): Batch size. Defaults to 1.
      det_batch_size (Optional[int]): Batch size for text detection
          model. Overwrite batch_size if it is not None.
          Defaults to None.
      rec_batch_size (Optional[int]): Batch size for text recognition
          model. Overwrite batch_size if it is not None.
          Defaults to None.
      kie_batch_size (Optional[int]): Batch size for KIE model.
          Overwrite batch_size if it is not None.
          Defaults to None.
      out_dir (str): Output directory of results. Defaults to 'results/'.
      return_vis (bool): Whether to return the visualization result.
          Defaults to False.
      save_vis (bool): Whether to save the visualization results to
          "out_dir". Defaults to False.
      save_pred (bool): Whether to save the inference results to
          "out_dir". Defaults to False.
      **kwargs: Key words arguments passed to :meth:`preprocess`,
          :meth:`forward`, :meth:`visualize` and :meth:`postprocess`.
          Each key in kwargs should be in the corresponding set of
          ``preprocess_kwargs``, ``forward_kwargs``, ``visualize_kwargs``
          and ``postprocess_kwargs``.
  
  Returns:
      dict: Inference and visualization results, mapped from
          "predictions" and "visualization".
docstr_tok: ["Call","the","inferencer",".","Args",":","inputs","(","InputsType",")",":","Inputs","for","the","inferencer",".","It","can","be","a","path","to","image","\/","image","directory",",","or","an","array",",","or","a","list","of","these",".","batch_size","(","int",")",":","Batch","size",".","Defaults","to","1.","det_batch_size","(","Optional","[","int","]",")",":","Batch","size","for","text","detection","model",".","Overwrite","batch_size","if","it","is","not","None",".","Defaults","to","None",".","rec_batch_size","(","Optional","[","int","]",")",":","Batch","size","for","text","recognition","model",".","Overwrite","batch_size","if","it","is","not","None",".","Defaults","to","None",".","kie_batch_size","(","Optional","[","int","]",")",":","Batch","size","for","KIE","model",".","Overwrite","batch_size","if","it","is","not","None",".","Defaults","to","None",".","out_dir","(","str",")",":","Output","directory","of","results",".","Defaults","to","'results\/","'",".","return_vis","(","bool",")",":","Whether","to","return","the","visualization","result",".","Defaults","to","False",".","save_vis","(","bool",")",":","Whether","to","save","the","visualization","results","to","``","out_dir","''",".","Defaults","to","False",".","save_pred","(","bool",")",":","Whether","to","save","the","inference","results","to","``","out_dir","''",".","Defaults","to","False",".","*","*","kwargs",":","Key","words","arguments","passed","to",":","meth",":","`","preprocess","`",",",":","meth",":","`","forward","`",",",":","meth",":","`","visualize","`","and",":","meth",":","`","postprocess","`",".","Each","key","in","kwargs","should","be","in","the","corresponding","set","of","``","preprocess_kwargs","``",",","``","forward_kwargs","``",",","``","visualize_kwargs","``","and","``","postprocess_kwargs","``",".","Returns",":","dict",":","Inference","and","visualization","results",",","mapped","from","``","predictions","''","and","``","visualization","''","."]
code: def __call__(
      self,
      inputs: InputsType,
      batch_size: int = 1,
      det_batch_size: Optional[int] = None,
      rec_batch_size: Optional[int] = None,
      kie_batch_size: Optional[int] = None,
      out_dir: str = "results/",
      return_vis: bool = False,
      save_vis: bool = False,
      save_pred: bool = False,
      **kwargs,
  ) -> dict:
      """Call the inferencer.
  
      Args:
          inputs (InputsType): Inputs for the inferencer. It can be a path
              to image / image directory, or an array, or a list of these.
          batch_size (int): Batch size. Defaults to 1.
          det_batch_size (Optional[int]): Batch size for text detection
              model. Overwrite batch_size if it is not None.
              Defaults to None.
          rec_batch_size (Optional[int]): Batch size for text recognition
              model. Overwrite batch_size if it is not None.
              Defaults to None.
          kie_batch_size (Optional[int]): Batch size for KIE model.
              Overwrite batch_size if it is not None.
              Defaults to None.
          out_dir (str): Output directory of results. Defaults to 'results/'.
          return_vis (bool): Whether to return the visualization result.
              Defaults to False.
          save_vis (bool): Whether to save the visualization results to
              "out_dir". Defaults to False.
          save_pred (bool): Whether to save the inference results to
              "out_dir". Defaults to False.
          **kwargs: Key words arguments passed to :meth:`preprocess`,
              :meth:`forward`, :meth:`visualize` and :meth:`postprocess`.
              Each key in kwargs should be in the corresponding set of
              ``preprocess_kwargs``, ``forward_kwargs``, ``visualize_kwargs``
              and ``postprocess_kwargs``.
  
      Returns:
          dict: Inference and visualization results, mapped from
              "predictions" and "visualization".
      """
      if (save_vis or save_pred) and not out_dir:
          raise ValueError(
              "out_dir must be specified when save_vis or "
              "save_pred is True!"
          )
      if out_dir:
          img_out_dir = osp.join(out_dir, "vis")
          pred_out_dir = osp.join(out_dir, "preds")
      else:
          img_out_dir, pred_out_dir = "", ""
  
      (
          preprocess_kwargs,
          forward_kwargs,
          visualize_kwargs,
          postprocess_kwargs,
      ) = self._dispatch_kwargs(
          save_vis=save_vis,
          save_pred=save_pred,
          return_vis=return_vis,
          **kwargs,
      )
  
      ori_inputs = self._inputs_to_list(inputs)
      if det_batch_size is None:
          det_batch_size = batch_size
      if rec_batch_size is None:
          rec_batch_size = batch_size
      if kie_batch_size is None:
          kie_batch_size = batch_size
  
      chunked_inputs = super(BaseMMOCRInferencer, self)._get_chunk_data(
          ori_inputs, batch_size
      )
      results = {"predictions": [], "visualization": []}
      for ori_input in track(chunked_inputs, description="Inference"):
          preds = self.forward(
              ori_input,
              det_batch_size=det_batch_size,
              rec_batch_size=rec_batch_size,
              kie_batch_size=kie_batch_size,
              **forward_kwargs,
          )
          visualization = self.visualize(
              ori_input,
              preds,
              img_out_dir=img_out_dir,
              **visualize_kwargs,
          )
          batch_res = self.postprocess(
              preds,
              visualization,
              pred_out_dir=pred_out_dir,
              **postprocess_kwargs,
          )
          results["predictions"].extend(batch_res["predictions"])
          if return_vis and batch_res["visualization"] is not None:
              results["visualization"].extend(
                  batch_res["visualization"]
              )
      return results
  
imports: import os.path
  from datetime import datetime
  from typing import Dict, List, Optional, Tuple, Union
  import mmcv
  import mmengine
  import numpy
  from rich.progress import track
  from mmocr.registry import VISUALIZERS
  from mmocr.structures import TextSpottingDataSample
  from mmocr.utils import ConfigType, bbox2poly, crop_img, poly2bbox
  from .base_mmocr_inferencer import BaseMMOCRInferencer, InputsType, PredType, ResType
  from .kie_inferencer import KIEInferencer
  from .textdet_inferencer import TextDetInferencer
  from .textrec_inferencer import TextRecInferencer
label_desc: Use image node_id 5 for calling the MMOCRInferencer obj's underlying member method code with example usage: obj.__call__(inputs, batch_size, det_batch_size, rec_batch_size, kie_batch_size, out_dir, return_vis, save_vis, save_pred) and returns: results