code: def test_rechunk():
      from ...merge.concat import DataFrameConcat
  
      raw = pd.DataFrame(np.random.rand(10, 10))
      df = from_pandas_df(raw, chunk_size=3)
      df2 = tile(df.rechunk(4))
  
      assert df2.shape == (10, 10)
      assert len(df2.chunks) == 9
  
      assert df2.chunks[0].shape == (4, 4)
      pd.testing.assert_index_equal(
          df2.chunks[0].index_value.to_pandas(), pd.RangeIndex(4)
      )
      pd.testing.assert_index_equal(
          df2.chunks[0].columns_value.to_pandas(), pd.RangeIndex(4)
      )
      pd.testing.assert_series_equal(
          df2.chunks[0].dtypes, raw.dtypes[:4]
      )
  
      assert df2.chunks[2].shape == (4, 2)
      pd.testing.assert_index_equal(
          df2.chunks[2].index_value.to_pandas(), pd.RangeIndex(4)
      )
      pd.testing.assert_index_equal(
          df2.chunks[2].columns_value.to_pandas(), pd.RangeIndex(8, 10)
      )
      pd.testing.assert_series_equal(
          df2.chunks[2].dtypes, raw.dtypes[-2:]
      )
  
      assert df2.chunks[-1].shape == (2, 2)
      pd.testing.assert_index_equal(
          df2.chunks[-1].index_value.to_pandas(), pd.RangeIndex(8, 10)
      )
      pd.testing.assert_index_equal(
          df2.chunks[-1].columns_value.to_pandas(), pd.RangeIndex(8, 10)
      )
      pd.testing.assert_series_equal(
          df2.chunks[-1].dtypes, raw.dtypes[-2:]
      )
  
      for c in df2.chunks:
          assert c.shape[1] == len(c.dtypes)
          assert len(c.columns_value.to_pandas()) == len(c.dtypes)
  
      columns = [np.random.bytes(10) for _ in range(10)]
      index = np.random.randint(-100, 100, size=(4,))
      raw = pd.DataFrame(
          np.random.rand(4, 10), index=index, columns=columns
      )
      df = from_pandas_df(raw, chunk_size=3)
      df2 = tile(df.rechunk(6))
  
      assert df2.shape == (4, 10)
      assert len(df2.chunks) == 2
  
      assert df2.chunks[0].shape == (4, 6)
      pd.testing.assert_index_equal(
          df2.chunks[0].index_value.to_pandas(),
          df.index_value.to_pandas(),
      )
      pd.testing.assert_index_equal(
          df2.chunks[0].columns_value.to_pandas(), pd.Index(columns[:6])
      )
      pd.testing.assert_series_equal(
          df2.chunks[0].dtypes, raw.dtypes[:6]
      )
  
      assert df2.chunks[1].shape == (4, 4)
      pd.testing.assert_index_equal(
          df2.chunks[1].index_value.to_pandas(),
          df.index_value.to_pandas(),
      )
      pd.testing.assert_index_equal(
          df2.chunks[1].columns_value.to_pandas(), pd.Index(columns[6:])
      )
      pd.testing.assert_series_equal(
          df2.chunks[1].dtypes, raw.dtypes[-4:]
      )
  
      for c in df2.chunks:
          assert c.shape[1] == len(c.dtypes)
          assert len(c.columns_value.to_pandas()) == len(c.dtypes)
  
      # test Series rechunk
      series = from_pandas_series(
          pd.Series(np.random.rand(10)), chunk_size=3
      )
      series2 = tile(series.rechunk(4))
  
      assert series2.shape == (10,)
      assert len(series2.chunks) == 3
      pd.testing.assert_index_equal(
          series2.index_value.to_pandas(), pd.RangeIndex(10)
      )
  
      assert series2.chunk_shape == (3,)
      assert series2.nsplits == ((4, 4, 2),)
      assert series2.chunks[0].shape == (4,)
      pd.testing.assert_index_equal(
          series2.chunks[0].index_value.to_pandas(), pd.RangeIndex(4)
      )
      assert series2.chunks[1].shape == (4,)
      pd.testing.assert_index_equal(
          series2.chunks[1].index_value.to_pandas(), pd.RangeIndex(4, 8)
      )
      assert series2.chunks[2].shape == (2,)
      pd.testing.assert_index_equal(
          series2.chunks[2].index_value.to_pandas(),
          pd.RangeIndex(8, 10),
      )
  
      series2 = tile(series.rechunk(1))
  
      assert series2.shape == (10,)
      assert len(series2.chunks) == 10
      pd.testing.assert_index_equal(
          series2.index_value.to_pandas(), pd.RangeIndex(10)
      )
      assert not any(
          isinstance(c.op, DataFrameConcat) for c in series2.chunks
      )
  
      assert series2.chunk_shape == (10,)
      assert series2.nsplits == ((1,) * 10,)
      assert series2.chunks[0].shape == (1,)
      pd.testing.assert_index_equal(
          series2.chunks[0].index_value.to_pandas(), pd.RangeIndex(1)
      )
  
      # no need to rechunk
      series2 = tile(series.rechunk(3))
      series = tile(series)
      assert series2.chunk_shape == series.chunk_shape
      assert series2.nsplits == series.nsplits
  
imports: from typing import List, Union
  import numpy
  import pandas
  import pytest
  from ....None import opcodes
  from ....config import options, option_context
  from ....core import OutputType, tile, Tileable
  from ....core.graph import TileableGraph, TileableGraphBuilder, TileContext, ChunkGraphBuilder
  from ....core.operand import OperandStage
  from ....tensor.core import TENSOR_TYPE
  from ...None import eval, cut, get_dummies, to_numeric
  from ...core import DATAFRAME_TYPE, SERIES_TYPE, SERIES_CHUNK_TYPE, INDEX_TYPE, CATEGORICAL_TYPE, CATEGORICAL_CHUNK_TYPE, DataFrameData, SeriesData
  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, astype
label_desc: Use image node_id 4 for calling a global function with example usage: test_rechunk() without return types