code: def test_duplicated(setup):
      # test dataframe drop
      rs = np.random.RandomState(0)
      raw = pd.DataFrame(
          rs.randint(1000, size=(20, 5)),
          columns=["c" + str(i + 1) for i in range(5)],
          index=["i" + str(j) for j in range(20)],
      )
      duplicate_lines = rs.randint(1000, size=5)
      for i in [1, 3, 10, 11, 15]:
          raw.iloc[i] = duplicate_lines
  
      with option_context({"combine_size": 2}):
          # test dataframe
          for chunk_size in [(8, 3), (20, 5)]:
              df = from_pandas_df(raw, chunk_size=chunk_size)
              if chunk_size[0] < len(raw):
                  methods = ["tree", "subset_tree", "shuffle"]
              else:
                  # 1 chunk
                  methods = [None]
              for method in methods:
                  for subset in [None, "c1", ["c1", "c2"]]:
                      for keep in ["first", "last", False]:
                          try:
                              r = df.duplicated(
                                  method=method,
                                  subset=subset,
                                  keep=keep,
                              )
                              result = r.execute().fetch()
                              expected = raw.duplicated(
                                  subset=subset, keep=keep
                              )
                              pd.testing.assert_series_equal(
                                  result, expected
                              )
                          except Exception as e:  # pragma: no cover
                              raise AssertionError(
                                  f"failed when method={method}, subset={subset}, "
                                  f"keep={keep}"
                              ) from e
  
          # test series
          s = raw["c3"]
  
          for tp, obj in [("series", s)]:
              for chunk_size in [8, 20]:
                  to_m = (
                      from_pandas_series
                      if tp == "series"
                      else from_pandas_index
                  )
                  mobj = to_m(obj, chunk_size=chunk_size)
                  if chunk_size < len(obj):
                      methods = ["tree", "shuffle"]
                  else:
                      # 1 chunk
                      methods = [None]
                  for method in methods:
                      for keep in ["first", "last", False]:
                          try:
                              r = mobj.duplicated(
                                  method=method, keep=keep
                              )
                              result = r.execute().fetch()
                              expected = obj.duplicated(keep=keep)
  
                              cmp = (
                                  pd.testing.assert_series_equal
                                  if tp == "series"
                                  else pd.testing.assert_index_equal
                              )
                              cmp(result, expected)
                          except Exception as e:  # pragma: no cover
                              raise AssertionError(
                                  f"failed when method={method}, keep={keep}"
                              ) from e
  
imports: import random
  from collections import OrderedDict
  import numpy
  import pandas
  import pytest
  import mars
  from ....config import options, option_context
  from ....dataframe import DataFrame, Series
  from ....tensor import arange, tensor
  from ....tensor.random import rand
  from ....tests.core import require_cudf
  from ....utils import lazy_import, pd_release_version, no_default
  from ...None import eval, cut, qcut, get_dummies
  from ...core import DATAFRAME_OR_SERIES_TYPE
  from ...datasource.dataframe import from_pandas
  from ...datasource.series import from_pandas
  from ...datasource.index import from_pandas
  from ..None import to_gpu, to_cpu
  from ..bloom_filter import filter_by_bloom_filter
  from ..shift import _enable_no_default, _with_column_freq_bug
  from ..to_numeric import to_numeric
  from ..rebalance import DataFrameRebalance
label_desc: Use image node_id 30 for calling a global function with example usage: test_duplicated(setup) without return types