code: def tensor_totype(t):
      dtype = torch.float if t.is_mps else torch.double
      return t.to(dtype=dtype)
  
imports: import contextlib
  import dataclasses
  import math
  import textwrap
  from typing import Any, Dict, Optional
  import torch
  from torch import inf
label_desc: Use image node_id 4 for calling a global function with example usage: tensor_totype(t) and returns: t