code: def _cast_to_torch_tensor(ar, **kwargs):
      if isinstance(ar, cp.ndarray):
          ar = torch.as_tensor(ar, device="cuda")
      elif isinstance(ar, np.ndarray):
          ar = torch.from_numpy(ar)
      else:
          ar = torch.as_tensor(ar)
      return ar
  
file_path: cugraph/python/cugraph/cugraph/gnn/feature_storage/feat_storage.py
imports: from __future__ import annotations
  from collections import defaultdict
  from typing import Sequence, Union
  import cudf
  import cupy
  import numpy
  import pandas
  from cugraph.utilities.utils import import_optional, MissingModule
label_desc: Use image node_id 2 for calling a global function with example usage: _cast_to_torch_tensor(ar) and returns: ar