code: def on_device(method) -> torch.Tensor:
      """
      Wraps a method to ensure the returned tensor is on the current device.
      """
  
      def wrapped(self, *args, **kwargs):
          tensor = method(self, *args, **kwargs)
          if isinstance(tensor, torch.Tensor):
              return tensor.to(get_accelerator().current_device())
          return tensor
  
      return wrapped
  
imports: from functools import reduce
  from typing import Iterable
  import torch
  from deepspeed.accelerator import get_accelerator
label_desc: Use image node_id 2 for calling a global function with example usage: on_device(method) and returns: wrapped, tensor, tensor