code: def torch_type_to_str(
      value: Union[torch.dtype, torch.device, torch.Size]
  ) -> str:
      """Converts torch types, commonly used in Ax, to string representations."""
      if isinstance(value, torch.dtype):
          return str(value)
      if isinstance(value, torch.device):
          return checked_cast(str, value.type)
      if isinstance(value, torch.Size):
          return json.dumps(list(value))
      raise ValueError(f"Object {value} was of unexpected torch type.")
  
imports: import json
  from typing import Union
  import torch
  from ax.utils.common.typeutils import checked_cast
label_desc: Use image node_id 1 for calling a global function with example usage: torch_type_to_str(value) and returns: str, checked_cast, json