code: def test_targetencoder_random(n_samples, dtype, stat):
      x = cp.random.randint(0, 1000, n_samples).astype(dtype)
      y = cp.random.randint(0, 2, n_samples).astype(dtype)
      xt = cp.random.randint(0, 1000, n_samples).astype(dtype)
  
      encoder = TargetEncoder(stat=stat)
      encoder.fit_transform(x, y)
      test_encoded = encoder.transform(xt)
  
      df_train = cudf.DataFrame({"x": x, "y": y})
      dg = df_train.groupby("x", as_index=False).agg({"y": stat})
      df_test = cudf.DataFrame({"x": xt})
      df_test["row_id"] = cp.arange(len(df_test))
      df_test = df_test.merge(dg, on="x", how="left")
      df_test = df_test.sort_values("row_id")
      answer = df_test["y"].fillna(eval(f"cp.{stat}")(y).item()).values
      assert array_equal(test_encoded, answer)
  
file_path: cuml/python/cuml/tests/test_target_encoder.py
imports: import pytest
  from cuml.testing.utils import array_equal
  from cuml.internals.safe_imports import cpu_only_import
  from cuml.preprocessing.TargetEncoder import TargetEncoder
  from cuml.internals.safe_imports import gpu_only_import
label_desc: Use image node_id 3 for calling a global function with example usage: test_targetencoder_random(n_samples, dtype, stat) without return types