code: def cast_to_tensor(ser: cudf.Series):
      if len(ser) == 0:
          # Empty series can not be converted to pytorch cuda tensor
          t = torch.from_numpy(ser.values.get())
          return t.to("cuda")
  
      return torch.as_tensor(ser.values, device="cuda")
  
imports: from __future__ import annotations
  from typing import List, Tuple, Dict, Optional
  from collections import defaultdict
  import cudf
  from cugraph.utilities.utils import import_optional
  from cugraph_dgl.nn import SparseGraph
label_desc: Use image node_id 1 for calling a global function with example usage: cast_to_tensor(ser) and returns: torch, t