code: def scalarize_dict_values(dict_with_tensors: Dict[str, Tensor]):
      """
      this method returns a new dict where the values of
      `dict_with_tensors` would be a scalar
  
      Returns:
          Dict: a new dict with scalarized values
      """
      dict_with_scalar_tensors = {}
      for key, val in dict_with_tensors.items():
          if torch.is_tensor(val):
              if val.dim() != 0:
                  val = val.mean()
          dict_with_scalar_tensors[key] = val
      return dict_with_scalar_tensors
  
imports: import collections
  import gc
  import logging
  import math
  import os
  import sys
  import time
  import warnings
  from bisect import bisect
  from typing import Any, Callable, Dict
  import torch
  from mmf.utils.distributed import get_rank, get_world_size, is_xla
  from mmf.utils.file_io import PathManager
  from packaging import version
  from torch import nn, Tensor
label_desc: Use image node_id 28 for calling a global function with example usage: scalarize_dict_values(dict_with_tensors) and returns: dict_with_scalar_tensors