code: def to_device(
      x: paddle.Tensor,
      device: core.Place,
      /,
      *,
      stream: Optional[int] = None,
      out: Optional[paddle.Tensor] = None,
  ) -> paddle.Tensor:
      device = as_native_dev(device)
      if device.is_cpu_place() and not x.place.is_cpu_place():
          return x.cpu()
      elif (device.is_gpu_place() and not x.place.is_gpu_place()) or (
          x.place.is_gpu_place()
          and device.is_gpu_place()
          and x.place.gpu_device_id() != device.gpu_device_id()
      ):
          return x.cuda(device.gpu_device_id())
      else:
          return x
  
imports: import os
  import paddle
  from typing import Optional, Union
  import time
  import ivy
  from ivy.functional.ivy.device import _shift_native_arrays_on_default_device, Profiler
  from paddle.device import core
label_desc: Use image node_id 2 for calling a global function with example usage: to_device() and returns: x, x, x