class_docstr: Base inferencer.
  
  Args:
      model (str, optional): Path to the config file or the model name
          defined in metafile. For example, it could be
          "dbnet_resnet18_fpnc_1200e_icdar2015" or
          "configs/textdet/dbnet/dbnet_resnet18_fpnc_1200e_icdar2015.py".
          If model is not specified, user must provide the
          `weights` saved by MMEngine which contains the config string.
          Defaults to None.
      weights (str, optional): Path to the checkpoint. If it is not specified
          and model is a model name of metafile, the weights will be loaded
          from metafile. Defaults to None.
      device (str, optional): Device to run inference. If None, the available
          device will be automatically used. Defaults to None.
      scope (str, optional): The scope of the model. Defaults to "mmocr".
docstr: Visualize predictions.
  
  Args:
      inputs (List[Union[str, np.ndarray]]): Inputs for the inferencer.
      preds (List[Dict]): Predictions of the model.
      return_vis (bool): Whether to return the visualization result.
          Defaults to False.
      show (bool): Whether to display the image in a popup window.
          Defaults to False.
      wait_time (float): The interval of show (s). Defaults to 0.
      draw_pred (bool): Whether to draw predicted bounding boxes.
          Defaults to True.
      pred_score_thr (float): Minimum score of bboxes to draw.
          Defaults to 0.3.
      save_vis (bool): Whether to save the visualization result. Defaults
          to False.
      img_out_dir (str): Output directory of visualization results.
          If left as empty, no file will be saved. Defaults to ''.
  
  Returns:
      List[np.ndarray] or None: Returns visualization results only if
      applicable.
docstr_tok: ["Visualize","predictions",".","Args",":","inputs","(","List","[","Union","[","str",",","np.ndarray","]","]",")",":","Inputs","for","the","inferencer",".","preds","(","List","[","Dict","]",")",":","Predictions","of","the","model",".","return_vis","(","bool",")",":","Whether","to","return","the","visualization","result",".","Defaults","to","False",".","show","(","bool",")",":","Whether","to","display","the","image","in","a","popup","window",".","Defaults","to","False",".","wait_time","(","float",")",":","The","interval","of","show","(","s",")",".","Defaults","to","0.","draw_pred","(","bool",")",":","Whether","to","draw","predicted","bounding","boxes",".","Defaults","to","True",".","pred_score_thr","(","float",")",":","Minimum","score","of","bboxes","to","draw",".","Defaults","to","0.3.","save_vis","(","bool",")",":","Whether","to","save","the","visualization","result",".","Defaults","to","False",".","img_out_dir","(","str",")",":","Output","directory","of","visualization","results",".","If","left","as","empty",",","no","file","will","be","saved",".","Defaults","to","``",".","Returns",":","List","[","np.ndarray","]","or","None",":","Returns","visualization","results","only","if","applicable","."]
code: def visualize(
      self,
      inputs: InputsType,
      preds: PredType,
      return_vis: bool = False,
      show: bool = False,
      wait_time: int = 0,
      draw_pred: bool = True,
      pred_score_thr: float = 0.3,
      save_vis: bool = False,
      img_out_dir: str = "",
  ) -> Union[List[np.ndarray], None]:
      """Visualize predictions.
  
      Args:
          inputs (List[Union[str, np.ndarray]]): Inputs for the inferencer.
          preds (List[Dict]): Predictions of the model.
          return_vis (bool): Whether to return the visualization result.
              Defaults to False.
          show (bool): Whether to display the image in a popup window.
              Defaults to False.
          wait_time (float): The interval of show (s). Defaults to 0.
          draw_pred (bool): Whether to draw predicted bounding boxes.
              Defaults to True.
          pred_score_thr (float): Minimum score of bboxes to draw.
              Defaults to 0.3.
          save_vis (bool): Whether to save the visualization result. Defaults
              to False.
          img_out_dir (str): Output directory of visualization results.
              If left as empty, no file will be saved. Defaults to ''.
  
      Returns:
          List[np.ndarray] or None: Returns visualization results only if
          applicable.
      """
      if self.visualizer is None or not (
          show or save_vis or return_vis
      ):
          return None
  
      if getattr(self, "visualizer") is None:
          raise ValueError(
              'Visualization needs the "visualizer" term'
              "defined in the config, but got None."
          )
  
      results = []
  
      for single_input, pred in zip(inputs, preds):
          if isinstance(single_input, str):
              img_bytes = mmengine.fileio.get(single_input)
              img = mmcv.imfrombytes(img_bytes, channel_order="rgb")
          elif isinstance(single_input, np.ndarray):
              img = single_input.copy()[:, :, ::-1]  # to RGB
          else:
              raise ValueError(
                  "Unsupported input type: " f"{type(single_input)}"
              )
          img_name = osp.splitext(osp.basename(pred.img_path))[0]
  
          if save_vis and img_out_dir:
              out_file = osp.splitext(img_name)[0]
              out_file = f"{out_file}.jpg"
              out_file = osp.join(img_out_dir, out_file)
          else:
              out_file = None
  
          visualization = self.visualizer.add_datasample(
              img_name,
              img,
              pred,
              show=show,
              wait_time=wait_time,
              draw_gt=False,
              draw_pred=draw_pred,
              pred_score_thr=pred_score_thr,
              out_file=out_file,
          )
          results.append(visualization)
  
      return results
  
imports: import os.path
  from typing import Dict, Iterable, List, Optional, Sequence, Tuple, Union
  import mmcv
  import mmengine
  import numpy
  from mmengine.dataset import Compose
  from mmengine.infer.infer import BaseInferencer, ModelType
  from mmengine.model.utils import revert_sync_batchnorm
  from mmengine.registry import init_default_scope
  from mmengine.structures import InstanceData
  from rich.progress import track
  from torch import Tensor
  from mmocr.utils import ConfigType
label_desc: Use image node_id 7 for calling the BaseMMOCRInferencer obj's underlying member method code with example usage: obj.visualize(inputs, preds, return_vis, show, wait_time, draw_pred, pred_score_thr, save_vis, img_out_dir) and returns: results, None