code: def test_consistent_state_for_dataset_fields():
      def check_asserts(data):
          np.testing.assert_allclose(data.label, data.get_label())
          np.testing.assert_allclose(
              data.label, data.get_field("label")
          )
          assert not np.isnan(data.label[0])
          assert not np.isinf(data.label[1])
          np.testing.assert_allclose(data.weight, data.get_weight())
          np.testing.assert_allclose(
              data.weight, data.get_field("weight")
          )
          assert not np.isnan(data.weight[0])
          assert not np.isinf(data.weight[1])
          np.testing.assert_allclose(
              data.init_score, data.get_init_score()
          )
          np.testing.assert_allclose(
              data.init_score, data.get_field("init_score")
          )
          assert not np.isnan(data.init_score[0])
          assert not np.isinf(data.init_score[1])
          assert np.all(
              np.isclose(
                  [data.label[0], data.weight[0], data.init_score[0]],
                  data.label[0],
              )
          )
          assert data.label[1] == pytest.approx(data.weight[1])
          assert data.feature_name == data.get_feature_name()
  
      X, y = load_breast_cancer(return_X_y=True)
      sequence = np.ones(y.shape[0])
      sequence[0] = np.nan
      sequence[1] = np.inf
      feature_names = [f"f{i}" for i in range(X.shape[1])]
      lgb_data = lgb.Dataset(
          X,
          sequence,
          weight=sequence,
          init_score=sequence,
          feature_name=feature_names,
      ).construct()
      check_asserts(lgb_data)
      lgb_data = lgb.Dataset(X, y).construct()
      lgb_data.set_label(sequence)
      lgb_data.set_weight(sequence)
      lgb_data.set_init_score(sequence)
      lgb_data.set_feature_name(feature_names)
      check_asserts(lgb_data)
  
imports: import filecmp
  import numbers
  import re
  from copy import deepcopy
  from os import getenv
  from pathlib import Path
  import numpy
  import pytest
  from scipy import sparse
  from sklearn.datasets import dump_svmlight_file, load_svmlight_file
  from sklearn.model_selection import train_test_split
  import lightgbm
  from lightgbm.compat import PANDAS_INSTALLED, pd_DataFrame, pd_Series
  from .utils import dummy_obj, load_breast_cancer, mse_obj, np_assert_array_equal
label_desc: Use image node_id 17 for calling a global function with example usage: test_consistent_state_for_dataset_fields() without return types