code: def dev(
      x: torch.Tensor, /, *, as_native: bool = False
  ) -> Union[ivy.Device, torch.device]:
      dv = x.device
      if as_native:
          if isinstance(dv, torch.device):
              dv = dv.type
          elif (
              hasattr(torch.backends, "mps")
              and torch.backends.mps.is_available()
          ):
              return torch.device(dv.replace("gpu", "mps"))
          return torch.device(dv.replace("gpu", "cuda"))
      return as_ivy_dev(dv)
  
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 1 for calling a global function with example usage: dev() and returns: as_ivy_dev, torch, torch