code: def test_dataframe_scatter_by_map(map_size, nelem, keep):
      strlist = [
          "dog",
          "cat",
          "fish",
          "bird",
          "pig",
          "fox",
          "cow",
          "goat",
      ]
      np.random.seed(0)
      df = DataFrame()
      df["a"] = np.random.choice(strlist[:map_size], nelem)
      df["b"] = np.random.uniform(low=0, high=map_size, size=nelem)
      df["c"] = np.random.randint(map_size, size=nelem)
      df["d"] = df["a"].astype("category")
  
      def _check_scatter_by_map(dfs, col):
          assert len(dfs) == map_size
          nrows = 0
          # print(col._column)
          name = col.name
          for i, df in enumerate(dfs):
              nrows += len(df)
              if len(df) > 0:
                  # Make sure the column types were preserved
                  assert isinstance(df[name]._column, type(col._column))
              try:
                  sr = df[name].astype(np.int32)
              except ValueError:
                  sr = df[name]
              assert sr.nunique() <= 1
              if sr.nunique() == 1:
                  if isinstance(df[name]._column, NumericalColumn):
                      assert sr.iloc[0] == i
          assert nrows == nelem
  
      with pytest.warns(UserWarning):
          _check_scatter_by_map(
              df.scatter_by_map("a", map_size, keep_index=keep), df["a"]
          )
      _check_scatter_by_map(
          df.scatter_by_map("b", map_size, keep_index=keep), df["b"]
      )
      _check_scatter_by_map(
          df.scatter_by_map("c", map_size, keep_index=keep), df["c"]
      )
      with pytest.warns(UserWarning):
          _check_scatter_by_map(
              df.scatter_by_map("d", map_size, keep_index=keep), df["d"]
          )
  
      if map_size == 2 and nelem == 100:
          with pytest.warns(UserWarning):
              df.scatter_by_map("a")  # Auto-detect map_size
          with pytest.raises(ValueError):
              with pytest.warns(UserWarning):
                  df.scatter_by_map(
                      "a", map_size=1, debug=True
                  )  # Bad map_size
  
      # Test GenericIndex
      df2 = df.set_index("c")
      generic_result = df2.scatter_by_map(
          "b", map_size, keep_index=keep
      )
      _check_scatter_by_map(generic_result, df2["b"])
      if keep:
          for frame in generic_result:
              isinstance(frame.index, type(df2.index))
  
      # Test MultiIndex
      df2 = df.set_index(["a", "c"])
      multiindex_result = df2.scatter_by_map(
          "b", map_size, keep_index=keep
      )
      _check_scatter_by_map(multiindex_result, df2["b"])
      if keep:
          for frame in multiindex_result:
              isinstance(frame.index, type(df2.index))
  
imports: import string
  from itertools import product
  import numpy
  import pandas
  import pytest
  from cudf import DataFrame, Series
  from cudf.core.column import NumericalColumn
  from cudf.testing._utils import DATETIME_TYPES, NUMERIC_TYPES, assert_eq, assert_exceptions_equal, expect_warning_if
label_desc: Use image node_id 16 for calling a global function with example usage: test_dataframe_scatter_by_map(map_size, nelem, keep) without return types