code: def handle_soft_device_variable(*args, fn, **kwargs):
      (
          args,
          kwargs,
          device_shifting_dev,
      ) = _shift_native_arrays_on_default_device(*args, **kwargs)
      # checking if this function accepts `device` argument
      # must be handled in the backend
      if "device" in inspect.signature(fn).parameters:
          kwargs["device"] = device_shifting_dev
      return fn(*args, **kwargs)
  
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 9 for calling a global function with example usage: handle_soft_device_variable() and returns: fn