code: def tensor_to_python_float(
      inp_tensor: Union[int, float, torch.Tensor],
      is_distributed: bool,
      reduce_op: str = "mean",
  ) -> Union[int, float, np.ndarray]:
      """
      Given a number or a Tensor (potentially in distributed setting) returns the float value.
      If is_distributed is true, the Tensor must be aggregated first.
  
      Args:
          inp_tensor: the input tensor
          is_distributed: indicates whether we are in distributed mode
          reduce_op: reduce operation for aggregation
              If equals to mean, will reduce using mean, otherwise sum operation
      """
      if is_distributed and isinstance(inp_tensor, torch.Tensor):
          if reduce_op == "mean":
              inp_tensor = reduce_tensor(inp_tensor=inp_tensor)
          else:
              inp_tensor = reduce_tensor_sum(inp_tensor=inp_tensor)
  
      if (
          isinstance(inp_tensor, torch.Tensor)
          and inp_tensor.numel() > 1
      ):
          # For IOU, we get a C-dimensional tensor (C - number of classes)
          # so, we convert here to a numpy array
          return inp_tensor.cpu().numpy()
      elif hasattr(inp_tensor, "item"):
          return inp_tensor.item()
      elif isinstance(inp_tensor, (int, float)):
          return inp_tensor * 1.0
      else:
          raise NotImplementedError(
              "The data type is not supported yet in tensor_to_python_float function"
          )
  
file_path: ml-cvnets/utils/tensor_utils.py
imports: from typing import Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from torch import Tensor
  from torch import distributed
  from common import DEFAULT_IMAGE_CHANNELS, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, DEFAULT_VIDEO_FRAMES
  from utils.third_party.ddp_functional_utils import all_gather
label_desc: Use image node_id 8 for calling a global function with example usage: tensor_to_python_float(inp_tensor, is_distributed, reduce_op) and returns: inp_tensor, inp_tensor, unknown