code: def get_scalar_from_ludwig_metric(metric: Metric) -> float:
      """Returns the scalar value of a Ludwig metric.
  
      Params:
          metric: Metric object
  
      Returns:
          float: scalar value of the metric
      """
      return metric.compute().detach().cpu().numpy().item()
  
file_path: ludwig/ludwig/utils/metric_utils.py
imports: from collections import defaultdict, namedtuple
  from typing import Dict, List, Optional
  import torch
  from torch import Tensor
  from torchmetrics.metric import Metric
  from ludwig.constants import COMBINED, LOSS, NAME, TYPE
  from ludwig.modules.metric_registry import get_metric_names_for_type
  from ludwig.types import FeatureConfigDict
label_desc: Use image node_id 4 for calling a global function with example usage: get_scalar_from_ludwig_metric(metric) and returns: metric