code: def _cast_if_autocast_enabled(tensor):
      if torch.is_autocast_enabled():
          if isinstance(tensor, torch.Tensor):
              if tensor.device.type == "cuda":
                  dtype = torch.get_autocast_gpu_dtype()
              elif tensor.device.type == "cpu":
                  dtype = torch.get_autocast_cpu_dtype()
              else:
                  raise NotImplementedError()
              return tensor.to(dtype=dtype)
      return tensor
  
imports: import itertools
  import math
  from typing import Dict, Iterator, List, Tuple, Union
  import torch
  import torch.nn
  from torch import Tensor
label_desc: Use image node_id 26 for calling a global function with example usage: _cast_if_autocast_enabled(tensor) and returns: tensor, tensor