code: def test_auto_merge_chunks():
      from ..merge import DataFrameConcat
  
      pdf = pd.DataFrame(np.random.rand(16, 4), columns=list("abcd"))
      memory_size = pdf.iloc[:4].memory_usage().sum()
  
      class FakeContext:
          def __init__(self, retval=True):
              self._retval = retval
  
          def get_chunks_meta(
              self, data_keys: List[str], **_
          ) -> List[Dict]:
              if self._retval:
                  return [{"memory_size": memory_size}] * len(data_keys)
              else:
                  return [None] * len(data_keys)
  
      df = tile(DataFrame(pdf, chunk_size=4))
      df2 = auto_merge_chunks(FakeContext(), df, 2 * memory_size)
      assert len(df2.chunks) == 2
      assert isinstance(df2.chunks[0].op, DataFrameConcat)
      assert len(df2.chunks[0].op.inputs) == 2
      assert isinstance(df2.chunks[1].op, DataFrameConcat)
      assert len(df2.chunks[1].op.inputs) == 2
  
      df2 = auto_merge_chunks(FakeContext(), df, 3 * memory_size)
      assert len(df2.chunks) == 2
      assert isinstance(df2.chunks[0].op, DataFrameConcat)
      assert len(df2.chunks[0].op.inputs) == 3
      assert not isinstance(df2.chunks[1].op, DataFrameConcat)
      assert len(df2.chunks[1].op.inputs) == 0
      assert df2.chunks[1].shape == df.chunks[-1].shape
      assert df2.chunks[1].index == (1, 0)
  
      # mock situation that df not executed
      df2 = auto_merge_chunks(FakeContext(False), df, 3 * memory_size)
      assert df2 is df
  
      # number of chunks on columns > 1
      df3 = tile(DataFrame(pdf, chunk_size=2))
      df4 = auto_merge_chunks(FakeContext(), df3, 2 * memory_size)
      assert df4 is df3
  
      # each chunk's size is greater than limit
      df5 = auto_merge_chunks(FakeContext(), df, memory_size / 5)
      assert all(
          (c1.shape == c2.shape)
          for c1, c2 in zip(df.chunks, df5.chunks)
      )
  
      # test series
      ps = pdf.loc[:, "a"]
      memory_size = ps.iloc[:4].memory_usage()
      s = tile(Series(ps, chunk_size=4))
      s2 = auto_merge_chunks(FakeContext(), s, 2 * memory_size)
      assert len(s2.chunks) == 2
      assert isinstance(s2.chunks[0].op, DataFrameConcat)
      assert s2.chunks[0].name == "a"
      assert len(s2.chunks[0].op.inputs) == 2
      assert isinstance(s2.chunks[1].op, DataFrameConcat)
      assert s2.chunks[1].name == "a"
      assert len(s2.chunks[1].op.inputs) == 2
  
imports: import operator
  from collections import OrderedDict
  from numbers import Integral
  from typing import List, Dict
  import numpy
  import pandas
  import pytest
  from ...config import option_context
  from ...core import tile
  from ...utils import Timer
  from ..core import IndexValue
  from ..initializer import DataFrame, Series, Index
  from ..utils import decide_dataframe_chunk_sizes, decide_series_chunk_size, split_monotonic_index_min_max, build_split_idx_to_origin_idx, parse_index, filter_index_value, infer_dtypes, infer_index_value, validate_axis, fetch_corner_data, make_dtypes, build_concatenated_rows_frame, merge_index_value, auto_merge_chunks, whether_to_clean_up
label_desc: Use image node_id 16 for calling a global function with example usage: test_auto_merge_chunks() and returns: unknown, unknown