class_docstr: PyTorch implementation for the inference.
  
  Args:
      path (str | Path): Path to Torch model weights.
      device (str): Device to use for inference. Options are auto, cpu, cuda. Defaults to "auto".
class_docstr_tok: ["PyTorch","implementation","for","the","inference",".","Args",":","path","(","str","|","Path",")",":","Path","to","Torch","model","weights",".","device","(","str",")",":","Device","to","use","for","inference",".","Options","are","auto",",","cpu",",","cuda",".","Defaults","to","``","auto","''","."]
docstr: Load metadata from file.
  
  Args:
      path (str | Path | dict): Path to the model pt file.
  
  Returns:
      dict: Dictionary containing the metadata.
docstr_tok: ["Load","metadata","from","file",".","Args",":","path","(","str","|","Path","|","dict",")",":","Path","to","the","model","pt","file",".","Returns",":","dict",":","Dictionary","containing","the","metadata","."]
code: def _load_metadata(
      self, path: str | Path | dict | None = None
  ) -> dict | DictConfig:
      """Load metadata from file.
  
      Args:
          path (str | Path | dict): Path to the model pt file.
  
      Returns:
          dict: Dictionary containing the metadata.
      """
      metadata: dict | DictConfig
  
      if isinstance(path, dict):
          metadata = path
      elif isinstance(path, (str, Path)):
          checkpoint = self._load_checkpoint(path)
  
          # Torch model should ideally contain the metadata in the checkpoint.
          # Check if the metadata is present in the checkpoint.
          if "metadata" not in checkpoint.keys():
              raise KeyError(
                  "``metadata`` is not found in the checkpoint. Please ensure that you save the model as Torch model."
              )
          metadata = checkpoint["metadata"]
      else:
          raise ValueError(f"Unknown ``path`` type {type(path)}")
  
      return metadata
  
imports: from __future__ import annotations
  from pathlib import Path
  from typing import Any, Sequence
  import albumentations
  import cv2
  import numpy
  import torch
  from omegaconf import DictConfig
  from torch import Tensor, nn
  from anomalib.data import TaskType
  from anomalib.data.utils.boxes import masks_to_boxes
  from .base_inferencer import Inferencer
label_desc: Use image node_id 4 for calling the TorchInferencer obj's underlying member method code with example usage: obj._load_metadata(path) and returns: metadata