code: def scalar_to_float(scalar: Scalar) -> float:
      if isinstance(scalar, Tensor):
          scalar = scalar.squeeze()
          numel = scalar.numel()
          if numel != 1:
              raise ValueError(
                  f"Scalar tensor must contain a single item, {numel} given."
              )
  
          return float(scalar.cpu().detach().numpy().item())
      elif isinstance(scalar, ndarray):
          numel = scalar.size
          if numel != 1:
              raise ValueError(
                  f"Scalar ndarray must contain a single item, {numel} given."
              )
          return float(scalar.item())
  
      return float(scalar)
  
imports: from numpy import ndarray
  from torch import Tensor
  from torchtnt.utils.loggers.logger import Scalar
label_desc: Use image node_id 1 for calling a global function with example usage: scalar_to_float(scalar) and returns: float, float, float