code: def test_sequence(
      tmpdir, sample_count, batch_size, include_0_and_nan, num_seq
  ):
      params = {"bin_construct_sample_cnt": sample_count}
  
      nrow = 50
      half_nrow = nrow // 2
      ncol = 11
      data = np.arange(nrow * ncol, dtype=np.float64).reshape(
          (nrow, ncol)
      )
  
      if include_0_and_nan:
          # whole col
          data[:, 0] = 0
          data[:, 1] = np.nan
  
          # half col
          data[:half_nrow, 3] = 0
          data[:half_nrow, 2] = np.nan
  
          data[half_nrow:-2, 4] = 0
          data[:half_nrow, 4] = np.nan
  
      X = data[:, :-1]
      Y = data[:, -1]
  
      npy_bin_fname = tmpdir / "data_from_npy.bin"
      seq_bin_fname = tmpdir / "data_from_seq.bin"
  
      # Create dataset from numpy array directly.
      ds = lgb.Dataset(X, label=Y, params=params)
      ds.save_binary(npy_bin_fname)
  
      # Create dataset using Sequence.
      seqs = _create_sequence_from_ndarray(X, num_seq, batch_size)
      seq_ds = lgb.Dataset(seqs, label=Y, params=params)
      seq_ds.save_binary(seq_bin_fname)
  
      assert filecmp.cmp(npy_bin_fname, seq_bin_fname)
  
      # Test for validation set.
      # Select some random rows as valid data.
      rng = (
          np.random.default_rng()
      )  # Pass integer to set seed when needed.
      valid_idx = (rng.random(10) * nrow).astype(np.int32)
      valid_data = data[valid_idx, :]
      valid_X = valid_data[:, :-1]
      valid_Y = valid_data[:, -1]
  
      valid_npy_bin_fname = tmpdir / "valid_data_from_npy.bin"
      valid_seq_bin_fname = tmpdir / "valid_data_from_seq.bin"
      valid_seq2_bin_fname = tmpdir / "valid_data_from_seq2.bin"
  
      valid_ds = lgb.Dataset(
          valid_X, label=valid_Y, params=params, reference=ds
      )
      valid_ds.save_binary(valid_npy_bin_fname)
  
      # From Dataset constructor, with dataset from numpy array.
      valid_seqs = _create_sequence_from_ndarray(
          valid_X, num_seq, batch_size
      )
      valid_seq_ds = lgb.Dataset(
          valid_seqs, label=valid_Y, params=params, reference=ds
      )
      valid_seq_ds.save_binary(valid_seq_bin_fname)
      assert filecmp.cmp(valid_npy_bin_fname, valid_seq_bin_fname)
  
      # From Dataset.create_valid, with dataset from sequence.
      valid_seq_ds2 = seq_ds.create_valid(
          valid_seqs, label=valid_Y, params=params
      )
      valid_seq_ds2.save_binary(valid_seq2_bin_fname)
      assert filecmp.cmp(valid_npy_bin_fname, valid_seq2_bin_fname)
  
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 3 for calling a global function with example usage: test_sequence(tmpdir, sample_count, batch_size, include_0_and_nan, num_seq) without return types