class_docstr: AnomalyModule to train, validate, predict and test images.
  
  Acts as a base class for all the Anomaly Modules in the library.
class_docstr_tok: ["AnomalyModule","to","train",",","validate",",","predict","and","test","images",".","Acts","as","a","base","class","for","all","the","Anomaly","Modules","in","the","library","."]
docstr: Sets the pixel/image metrics.
  
  Args:
  name (str): is it pixel or image.
  state_dict (OrderedDict[str, Tensor]): state dict of the model.
docstr_tok: ["Sets","the","pixel\/image","metrics",".","Args",":","name","(","str",")",":","is","it","pixel","or","image",".","state_dict","(","OrderedDict","[","str",",","Tensor","]",")",":","state","dict","of","the","model","."]
code: def _set_metrics(
      self, name: str, state_dict: OrderedDict[str, Tensor]
  ):
      """Sets the pixel/image metrics.
  
      Args:
      name (str): is it pixel or image.
      state_dict (OrderedDict[str, Tensor]): state dict of the model.
      """
      metric_keys = [
          key
          for key in state_dict.keys()
          if key.startswith(f"{name}_metrics")
      ]
      if not hasattr(self, f"{name}_metrics") and any(metric_keys):
          metrics = AnomalibMetricCollection([], prefix=f"{name}_")
          for key in metric_keys:
              class_name = key.split(".")[1]
              try:
                  metrics_module = importlib.import_module(
                      "anomalib.utils.metrics"
                  )
                  metrics_cls = getattr(metrics_module, class_name)
              except Exception as exception:
                  raise ImportError(
                      f"Class {class_name} not found in module anomalib.utils.metrics"
                  ) from exception
              metrics.add_metrics(metrics_cls())
          setattr(self, f"{name}_metrics", metrics)
  
imports: from __future__ import annotations
  import importlib
  import logging
  from abc import ABC
  from typing import Any, OrderedDict
  from warnings import warn
  import pytorch_lightning
  import torch
  from pytorch_lightning.callbacks import Callback
  from pytorch_lightning.utilities.types import EPOCH_OUTPUT, STEP_OUTPUT
  from torch import Tensor, nn
  from torchmetrics import Metric
  from anomalib.data.utils import boxes_to_anomaly_maps, boxes_to_masks, masks_to_boxes
  from anomalib.post_processing import ThresholdMethod
  from anomalib.utils.metrics import AnomalibMetricCollection, AnomalyScoreDistribution, AnomalyScoreThreshold, MinMax
label_desc: Use image node_id 17 for calling the AnomalyModule obj's underlying member method code with example usage: obj._set_metrics(name, state_dict) without return types