code: def test_mars_dataset(setup_cluster):
      import numpy as np
      import pandas as pd
  
      tf_dataset_ops = lazy_import(
          "tensorflow.python.data.ops.dataset_ops"
      )
  
      # Mars tensor
      data = mt.random.rand(1000, 32, dtype="f4")
      data_verify = data[:10].execute().fetch()
  
      dataset = gen_tensorflow_dataset(data)
      assert isinstance(dataset, tf_dataset_ops.DatasetV2)
      for _, data_1batch in enumerate(
          dataset.repeat().batch(10).take(1)
      ):
          np.testing.assert_array_equal(data_1batch, data_verify)
  
      # Mars tensors
      data = mt.random.rand(1000, 32, dtype="f4")
      labels = mt.random.randint(0, 2, (1000, 10), dtype="f4")
  
      data_verify = data[:10].execute().fetch()
      labels_verify = labels[:10].execute().fetch()
  
      dataset = gen_tensorflow_dataset((data, labels))
      assert isinstance(dataset, tf_dataset_ops.DatasetV2)
      for _, (data_1batch, label_1batch) in enumerate(
          dataset.repeat().batch(10).take(1)
      ):
          np.testing.assert_array_equal(data_1batch, data_verify)
          np.testing.assert_array_equal(label_1batch, labels_verify)
  
      # np ndarray
      data = np.random.rand(1000, 32)
      labels = np.random.randint(0, 2, (1000, 10))
  
      data_verify = data[:10]
      labels_verify = labels[:10]
  
      dataset = gen_tensorflow_dataset((data, labels))
      assert isinstance(dataset, tf_dataset_ops.DatasetV2)
      for _, (data_1batch, label_1batch) in enumerate(
          dataset.repeat().batch(10).take(1)
      ):
          np.testing.assert_array_equal(data_1batch, data_verify)
          np.testing.assert_array_equal(label_1batch, labels_verify)
  
      # Mars dataframe
      data = md.DataFrame(data)
      labels = md.DataFrame(labels)
  
      data_verify = data.iloc[:10].execute().fetch().values
      labels_verify = labels.iloc[:10].execute().fetch().values
  
      dataset = gen_tensorflow_dataset(
          (data, labels),
          fetch_kwargs={"extra_config": {"check_series_name": False}},
      )
      assert isinstance(dataset, tf_dataset_ops.DatasetV2)
      for _, (data_1batch, label_1batch) in enumerate(
          dataset.repeat().batch(10).take(1)
      ):
          np.testing.assert_array_equal(data_1batch, data_verify)
          np.testing.assert_array_equal(label_1batch, labels_verify)
  
      # Mars series
      label = labels[1]
  
      label_verify = label[:10].execute().fetch()
  
      dataset = gen_tensorflow_dataset(
          (data, label),
          fetch_kwargs={"extra_config": {"check_series_name": False}},
      )
      assert isinstance(dataset, tf_dataset_ops.DatasetV2)
      for _, (data_1batch, label_1batch) in enumerate(
          dataset.repeat().batch(10).take(1)
      ):
          np.testing.assert_array_equal(data_1batch, data_verify)
          np.testing.assert_array_equal(label_1batch, label_verify)
  
      # pandas dataframe
      data = pd.DataFrame(np.random.rand(1000, 32))
      labels = pd.DataFrame(
          np.random.randint(0, 2, (1000, 10)), dtype="float32"
      )
  
      data_verify = data.iloc[:10].values
      labels_verify = labels.iloc[:10].values
      dataset = gen_tensorflow_dataset((data, labels))
      assert isinstance(dataset, tf_dataset_ops.DatasetV2)
      for _, (data_1batch, label_1batch) in enumerate(
          dataset.repeat().batch(10).take(1)
      ):
          np.testing.assert_array_equal(data_1batch, data_verify)
          np.testing.assert_array_equal(label_1batch, labels_verify)
  
      # pandas series
      label = labels[1]
  
      label_verify = label[:10]
  
      dataset = gen_tensorflow_dataset((data, label))
      assert isinstance(dataset, tf_dataset_ops.DatasetV2)
      for _, (data_1batch, label_1batch) in enumerate(
          dataset.repeat().batch(10).take(1)
      ):
          np.testing.assert_array_equal(data_1batch, data_verify)
          np.testing.assert_array_equal(label_1batch, label_verify)
  
      # list
      label = label.tolist()
  
      label_verify = label[:10]
  
      dataset = gen_tensorflow_dataset((data, label))
      assert isinstance(dataset, tf_dataset_ops.DatasetV2)
      for _, (data_1batch, label_1batch) in enumerate(
          dataset.repeat().batch(10).take(1)
      ):
          np.testing.assert_array_equal(data_1batch, data_verify)
          np.testing.assert_array_equal(label_1batch, label_verify)
  
      # test TypeError
      label = tuple(range(1000))
  
      with pytest.raises(TypeError) as e:
          dataset = gen_tensorflow_dataset((data, label))
      exec_msg = e.value.args[0]
      assert exec_msg == "Unexpected dataset type: <class 'tuple'>"
  
file_path: mars/mars/learn/contrib/tensorflow/tests/test_dataset.py
imports: import pytest
  import os
  from .....None import tensor
  from .....None import dataframe
  from .....utils import lazy_import
  from ..None import gen_tensorflow_dataset, run_tensorflow_script
label_desc: Use image node_id 1 for calling a global function with example usage: test_mars_dataset(setup_cluster) without return types