code: def test_dataframe_to_struct():
      df = cudf.DataFrame()
      expect = cudf.Series(dtype=cudf.StructDtype({}))
      got = df.to_struct()
      assert_eq(expect, got)
  
      df = cudf.DataFrame({"a": [1, 2, 3], "b": ["x", "y", "z"]})
      expect = cudf.Series(
          [{"a": 1, "b": "x"}, {"a": 2, "b": "y"}, {"a": 3, "b": "z"}]
      )
      got = df.to_struct()
      assert_eq(expect, got)
  
      # check that a copy was made:
      df["a"][0] = 5
      assert_eq(got, expect)
  
      # check that a non-string (but convertible to string) named column can be
      # converted to struct
      df = cudf.DataFrame([[1, 2], [3, 4]], columns=[(1, "b"), 0])
      expect = cudf.Series(
          [{"(1, 'b')": 1, "0": 2}, {"(1, 'b')": 3, "0": 4}]
      )
      with pytest.warns(UserWarning, match="will be casted"):
          got = df.to_struct()
      assert_eq(got, expect)
  
imports: import numpy
  import pandas
  import pyarrow
  import pytest
  import cudf
  from cudf.core.dtypes import StructDtype
  from cudf.testing._utils import DATETIME_TYPES, TIMEDELTA_TYPES, assert_eq
label_desc: Use image node_id 13 for calling a global function with example usage: test_dataframe_to_struct() without return types