code: def as_native_dev(
      device: Optional[Union[ivy.Device, torch.device]] = None,
      /,
  ) -> Optional[torch.device]:
      if not isinstance(device, str):
          return device
      if (
          hasattr(torch.backends, "mps")
          and torch.backends.mps.is_available()
      ):
          return torch.device(ivy.Device(device).replace("gpu", "mps"))
      return torch.device(ivy.Device(device).replace("gpu", "cuda"))
  
imports: import inspect
  import os
  import importlib
  import torch
  from typing import Optional, Union
  from torch.profiler import ProfilerActivity
  from torch.profiler import profile
  import ivy
  from ivy.functional.ivy.device import _shift_native_arrays_on_default_device, Profiler
label_desc: Use image node_id 4 for calling a global function with example usage: as_native_dev() and returns: torch, device, torch