code: def get_mps_device_if_available() -> torch.device:
      """Tries to get mps device, if fail, returns cpu.
  
      Returns:
          torch.device
      """
      dev = "cpu"
      if hasattr(torch.backends, "mps"):
          if torch.backends.mps.is_available():
              dev = "mps"
      return torch.device(dev)
  
imports: import platform
  import sys
  import warnings
  from functools import wraps
  from inspect import isclass, isfunction
  from typing import TYPE_CHECKING, Any, Callable, List, Optional, Tuple, Union, overload
  import torch
  from torch.linalg import inv_ex
  from kornia.core import Tensor
  from kornia.utils._compat import torch_version_ge
label_desc: Use image node_id 2 for calling a global function with example usage: get_mps_device_if_available() and returns: torch