code: def cast_tensor_to_fp32(
      tensor: Union[torch.Tensor, StatefulTensor]
  ) -> torch.Tensor:
      if isinstance(tensor, StatefulTensor):
          tensor = tensor.payload
  
      if torch.is_floating_point(tensor) and tensor.dtype in (
          torch.float16,
          torch.bfloat16,
      ):
          return tensor.float()
      return tensor
  
file_path: colossalai/colossalai/legacy/zero/sharded_model/_utils.py
imports: from typing import Any, Callable, List, Tuple, Union
  import torch
  import torch.nn.functional
  from colossalai.legacy.zero.gemini.stateful_tensor import StatefulTensor
label_desc: Use image node_id 5 for calling a global function with example usage: cast_tensor_to_fp32(tensor) and returns: tensor, tensor