code: def get_single_model_metrics(
      model_config: DictConfig | ListConfig,
      openvino_metrics: bool = False,
  ) -> dict:
      """Collects metrics for `model_name` and returns a dict of results.
  
      Args:
          model_config (DictConfig, ListConfig): Configuration for run
          openvino_metrics (bool): If True, converts the model to OpenVINO format and gathers inference metrics.
  
      Returns:
          dict: Collection of all the metrics such as time taken, throughput and performance scores.
      """
  
      with TemporaryDirectory() as project_path:
          model_config.project.path = project_path
          datamodule = get_datamodule(model_config)
          model = get_model(model_config)
  
          callbacks = get_sweep_callbacks(model_config)
  
          trainer = Trainer(
              **model_config.trainer, logger=None, callbacks=callbacks
          )
  
          start_time = time.time()
  
          trainer.fit(model=model, datamodule=datamodule)
  
          # get start time
          training_time = time.time() - start_time
  
          # Creating new variable is faster according to https://stackoverflow.com/a/4330829
          start_time = time.time()
          # get test results
          test_results = trainer.test(
              model=model, datamodule=datamodule
          )
  
          # get testing time
          testing_time = time.time() - start_time
  
          # Create dirs for torch export (as default only lighting model is produced)
          export(
              task=model_config.dataset.task,
              transform=trainer.datamodule.test_data.transform.to_dict(),
              input_size=model_config.model.input_size,
              model=model,
              export_mode=ExportMode.TORCH,
              export_root=project_path,
          )
  
          throughput = get_torch_throughput(
              model_path=project_path,
              test_dataset=datamodule.test_dataloader().dataset,
              device=model_config.trainer.accelerator,
          )
  
          # Get OpenVINO metrics
          openvino_throughput = float("nan")
          if openvino_metrics:
              # Create dirs for openvino model export
              export(
                  task=model_config.dataset.task,
                  transform=trainer.datamodule.test_data.transform.to_dict(),
                  input_size=model_config.model.input_size,
                  model=model,
                  export_mode=ExportMode.OPENVINO,
                  export_root=project_path,
              )
              openvino_throughput = get_openvino_throughput(
                  model_path=project_path,
                  test_dataset=datamodule.test_data,
              )
  
          # arrange the data
          data = {
              "Training Time (s)": training_time,
              "Testing Time (s)": testing_time,
              f"Inference Throughput {model_config.trainer.accelerator} (fps)": throughput,
              "OpenVINO Inference Throughput (fps)": openvino_throughput,
          }
          for key, val in test_results[0].items():
              data[key] = float(val)
  
      return data
  
imports: from __future__ import annotations
  import functools
  import io
  import logging
  import math
  import multiprocessing
  import sys
  import time
  import warnings
  from argparse import ArgumentParser
  from concurrent.futures import ProcessPoolExecutor, as_completed
  from datetime import datetime
  from pathlib import Path
  from tempfile import TemporaryDirectory
  from typing import cast
  import torch
  from omegaconf import DictConfig, ListConfig, OmegaConf
  from pytorch_lightning import Trainer, seed_everything
  from utils import upload_to_comet, upload_to_wandb, write_metrics
  from anomalib.config import get_configurable_parameters, update_input_size_config
  from anomalib.data import get_datamodule
  from anomalib.deploy import export
  from anomalib.deploy.export import ExportMode
  from anomalib.models import get_model
  from anomalib.utils.loggers import configure_logger
  from anomalib.utils.sweep import get_openvino_throughput, get_run_config, get_sweep_callbacks, get_torch_throughput, set_in_nested_config
label_desc: Use image node_id 2 for calling a global function with example usage: get_single_model_metrics(model_config, openvino_metrics) and returns: data