code: def get_inferencer(
      weight_path: Path, metadata: Path | None = None
  ) -> Inferencer:
      """Parse args and open inferencer.
  
      Args:
          weight_path (Path): Path to model weights.
          metadata (Path | None, optional): Metadata is required for OpenVINO models. Defaults to None.
  
      Raises:
          ValueError: If unsupported model weight is passed.
  
      Returns:
          Inferencer: Torch or OpenVINO inferencer.
      """
  
      # Get the inferencer. We use .ckpt extension for Torch models and (onnx, bin)
      # for the openvino models.
      extension = weight_path.suffix
      inferencer: Inferencer
      module = import_module("anomalib.deploy")
      if extension in (".pt", ".pth", ".ckpt"):
          torch_inferencer = getattr(module, "TorchInferencer")
          inferencer = torch_inferencer(path=weight_path)
  
      elif extension in (".onnx", ".bin", ".xml"):
          if metadata is None:
              raise ValueError(
                  "When using OpenVINO Inferencer, the following arguments are required: --metadata"
              )
  
          openvino_inferencer = getattr(module, "OpenVINOInferencer")
          inferencer = openvino_inferencer(
              path=weight_path, metadata=metadata
          )
  
      else:
          raise ValueError(
              f"Model extension is not supported. Torch Inferencer exptects a .ckpt file,"
              f"OpenVINO Inferencer expects either .onnx, .bin or .xml file. Got {extension}"
          )
  
      return inferencer
  
file_path: anomalib/tools/inference/gradio_inference.py
imports: from __future__ import annotations
  from argparse import ArgumentParser
  from importlib import import_module
  from pathlib import Path
  import gradio
  import gradio.inputs
  import gradio.outputs
  import numpy
  from anomalib.deploy import Inferencer
label_desc: Use image node_id 2 for calling a global function with example usage: get_inferencer(weight_path, metadata) and returns: inferencer