class_docstr: Key Information Extraction Inferencer.
  
  Args:
      model (str, optional): Path to the config file or the model name
          defined in metafile. For example, it could be
          "sdmgr_unet16_60e_wildreceipt" or
          "configs/kie/sdmgr/sdmgr_unet16_60e_wildreceipt.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".
class_docstr_tok: ["Key","Information","Extraction","Inferencer",".","Args",":","model","(","str",",","optional",")",":","Path","to","the","config","file","or","the","model","name","defined","in","metafile",".","For","example",",","it","could","be","``","sdmgr_unet16_60e_wildreceipt","''","or","``","configs\/kie\/sdmgr\/sdmgr_unet16_60e_wildreceipt.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: Preprocess the inputs to a list.
  
  Preprocess inputs to a list according to its type.
  
  The inputs can be a dict or list[dict], where each dictionary contains
  following keys:
  
  - img (str or ndarray): Path to the image or the image itself. If KIE
    Inferencer is used in no-visual mode, this key is not required.
    Note: If it's an numpy array, it should be in BGR order.
  - img_shape (tuple(int, int)): Image shape in (H, W). In
  - instances (list[dict]): A list of instances.
      - bbox (ndarray(dtype=np.float32)): Shape (4, ). Bounding box.
      - text (str): Annotation text.
  
  Each ``instance`` looks like the following:
  
  .. code-block:: python
  
  {
      # A nested list of 4 numbers representing the bounding box of
      # the instance, in (x1, y1, x2, y2) order.
      'bbox': np.array([[x1, y1, x2, y2], [x1, y1, x2, y2], ...],
                      dtype=np.int32),
  
      # List of texts.
      "texts": ['text1', 'text2', ...],
  }
  
  Args:
      inputs (InputsType): Inputs for the inferencer.
  
  Returns:
      list: List of input for the :meth:`preprocess`.
docstr_tok: ["Preprocess","the","inputs","to","a","list",".","Preprocess","inputs","to","a","list","according","to","its","type",".","The","inputs","can","be","a","dict","or","list","[","dict","]",",","where","each","dictionary","contains","following","keys",":","-","img","(","str","or","ndarray",")",":","Path","to","the","image","or","the","image","itself",".","If","KIE","Inferencer","is","used","in","no-visual","mode",",","this","key","is","not","required",".","Note",":","If","it","'s","an","numpy","array",",","it","should","be","in","BGR","order",".","-","img_shape","(","tuple","(","int",",","int",")",")",":","Image","shape","in","(","H",",","W",")",".","In","-","instances","(","list","[","dict","]",")",":","A","list","of","instances",".","-","bbox","(","ndarray","(","dtype=np.float32",")",")",":","Shape","(","4",",",")",".","Bounding","box",".","-","text","(","str",")",":","Annotation","text",".","Each","``","instance","``","looks","like","the","following",":","..","code-block",":",":","python","{","#","A","nested","list","of","4","numbers","representing","the","bounding","box","of","#","the","instance",",","in","(","x1",",","y1",",","x2",",","y2",")","order",".","'bbox","'",":","np.array","(","[","[","x1",",","y1",",","x2",",","y2","]",",","[","x1",",","y1",",","x2",",","y2","]",",","...","]",",","dtype=np.int32",")",",","#","List","of","texts",".","``","texts","''",":","[","'text1","'",",","'text2","'",",","...","]",",","}","Args",":","inputs","(","InputsType",")",":","Inputs","for","the","inferencer",".","Returns",":","list",":","List","of","input","for","the",":","meth",":","`","preprocess","`","."]
code: def _inputs_to_list(self, inputs: InputsType) -> list:
      """Preprocess the inputs to a list.
  
      Preprocess inputs to a list according to its type.
  
      The inputs can be a dict or list[dict], where each dictionary contains
      following keys:
  
      - img (str or ndarray): Path to the image or the image itself. If KIE
        Inferencer is used in no-visual mode, this key is not required.
        Note: If it's an numpy array, it should be in BGR order.
      - img_shape (tuple(int, int)): Image shape in (H, W). In
      - instances (list[dict]): A list of instances.
          - bbox (ndarray(dtype=np.float32)): Shape (4, ). Bounding box.
          - text (str): Annotation text.
  
      Each ``instance`` looks like the following:
  
      .. code-block:: python
  
      {
          # A nested list of 4 numbers representing the bounding box of
          # the instance, in (x1, y1, x2, y2) order.
          'bbox': np.array([[x1, y1, x2, y2], [x1, y1, x2, y2], ...],
                          dtype=np.int32),
  
          # List of texts.
          "texts": ['text1', 'text2', ...],
      }
  
      Args:
          inputs (InputsType): Inputs for the inferencer.
  
      Returns:
          list: List of input for the :meth:`preprocess`.
      """
  
      processed_inputs = []
  
      if not isinstance(inputs, (list, tuple)):
          inputs = [inputs]
  
      for single_input in inputs:
          if self.novisual:
              processed_input = copy.deepcopy(single_input)
              if (
                  "img" not in single_input
                  and "img_shape" not in single_input
              ):
                  raise ValueError(
                      "KIEInferencer in no-visual mode "
                      'requires input has "img" or "img_shape", but both are'
                      " not found."
                  )
              if "img" in single_input:
                  img = single_input["img"]
                  if isinstance(img, str):
                      img_bytes = mmengine.fileio.get(img)
                      img = mmcv.imfrombytes(img_bytes)
                      processed_input["img"] = img
                  processed_input["img_shape"] = img.shape[:2]
              processed_inputs.append(processed_input)
          else:
              if "img" not in single_input:
                  raise ValueError(
                      "This inferencer is constructed to "
                      "accept image inputs, but the input does not contain "
                      '"img" key.'
                  )
              if isinstance(single_input["img"], str):
                  processed_input = {
                      k: v
                      for k, v in single_input.items()
                      if k != "img"
                  }
                  processed_input["img_path"] = single_input["img"]
                  processed_inputs.append(processed_input)
              elif isinstance(single_input["img"], np.ndarray):
                  processed_inputs.append(copy.deepcopy(single_input))
              else:
                  atype = type(single_input["img"])
                  raise ValueError(f"Unsupported input type: {atype}")
  
      return processed_inputs
  
imports: import copy
  import os.path
  from typing import Any, Dict, List, Optional, Sequence, Union
  import mmcv
  import mmengine
  import numpy
  from mmengine.dataset import Compose, pseudo_collate
  from mmengine.runner.checkpoint import _load_checkpoint
  from mmocr.registry import DATASETS
  from mmocr.structures import KIEDataSample
  from mmocr.utils import ConfigType
  from .base_mmocr_inferencer import BaseMMOCRInferencer, ModelType, PredType
label_desc: Use image node_id 5 for calling the KIEInferencer obj's underlying member method code with example usage: obj._inputs_to_list(inputs) and returns: processed_inputs