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: Initialize the test pipeline.
docstr_tok: ["Initialize","the","test","pipeline","."]
code: def _init_pipeline(self, cfg: ConfigType) -> None:
      """Initialize the test pipeline."""
      pipeline_cfg = cfg.test_dataloader.dataset.pipeline
      idx = self._get_transform_idx(pipeline_cfg, "LoadKIEAnnotations")
      if idx == -1:
          raise ValueError(
              "LoadKIEAnnotations is not found in the test pipeline"
          )
      pipeline_cfg[idx]["with_label"] = False
      self.novisual = all(
          self._get_transform_idx(pipeline_cfg, t) == -1
          for t in self.loading_transforms
      )
      # Remove Resize from test_pipeline, since SDMGR requires bbox
      # annotations to be resized together with pictures, but visualization
      # loads the original image from the disk.
      # TODO: find a more elegant way to fix this
      idx = self._get_transform_idx(pipeline_cfg, "Resize")
      if idx != -1:
          pipeline_cfg.pop(idx)
      # If it's in non-visual mode, self.pipeline will be specified.
      # Otherwise, file_pipeline and ndarray_pipeline will be specified.
      if self.novisual:
          return Compose(pipeline_cfg)
      return super()._init_pipeline(cfg)
  
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 3 for calling the KIEInferencer obj's underlying member method code with example usage: obj._init_pipeline(cfg) and returns: super, Compose