code: def test_disk_iterate_batch():
      all_batch_sizes = [None, 32, 17, 11]
      all_shard_sizes = [
          [7, 3, 12, 4, 5],
          [1, 1, 1, 1, 1],
          [31, 31, 31, 31, 31],
          [21, 11, 41, 21, 51],
      ]
  
      for idx in range(25):
          shard_length = random.randint(1, 32)
          shard_sizes = []
          for _ in range(shard_length):
              shard_sizes.append(random.randint(1, 128))
          all_shard_sizes.append(shard_sizes)
          if idx == 0:
              # special case to test
              all_batch_sizes.append(None)
          else:
              all_batch_sizes.append(random.randint(1, 256))
  
      for shard_sizes, batch_size in zip(
          all_shard_sizes, all_batch_sizes
      ):
          all_Xs, all_ys, all_ws, all_ids = [], [], [], []
  
          def shard_generator():
              for sz in shard_sizes:
                  X_b = np.random.rand(sz, 1)
                  y_b = np.random.rand(sz, 1)
                  w_b = np.random.rand(sz, 1)
                  ids_b = np.random.rand(sz)
  
                  all_Xs.append(X_b)
                  all_ys.append(y_b)
                  all_ws.append(w_b)
                  all_ids.append(ids_b)
  
                  yield X_b, y_b, w_b, ids_b
  
          dataset = dc.data.DiskDataset.create_dataset(
              shard_generator()
          )
  
          all_Xs = np.concatenate(all_Xs, axis=0)
          all_ys = np.concatenate(all_ys, axis=0)
          all_ws = np.concatenate(all_ws, axis=0)
          all_ids = np.concatenate(all_ids, axis=0)
  
          total_size = sum(shard_sizes)
  
          assert dataset.X.shape[0] == total_size
  
          # deterministic
          test_Xs, test_ys, test_ws, test_ids = [], [], [], []
          for bidx, (a, b, c, d) in enumerate(
              dataset.iterbatches(
                  batch_size=batch_size,
                  pad_batches=False,
                  deterministic=True,
              )
          ):
              test_Xs.append(a)
              test_ys.append(b)
              test_ws.append(c)
              test_ids.append(d)
  
          if batch_size is None:
              for idx, (tx, ty, tw, tids) in enumerate(
                  zip(test_Xs, test_ys, test_ws, test_ids)
              ):
                  assert len(tx) == shard_sizes[idx]
                  assert len(ty) == shard_sizes[idx]
                  assert len(tw) == shard_sizes[idx]
                  assert len(tids) == shard_sizes[idx]
  
          test_Xs = np.concatenate(test_Xs, axis=0)
          test_ys = np.concatenate(test_ys, axis=0)
          test_ws = np.concatenate(test_ws, axis=0)
          test_ids = np.concatenate(test_ids, axis=0)
  
          if batch_size is None:
              assert bidx == len(shard_sizes) - 1
          else:
              assert bidx == math.ceil(total_size / batch_size) - 1
  
          np.testing.assert_array_equal(all_Xs, test_Xs)
          np.testing.assert_array_equal(all_ys, test_ys)
          np.testing.assert_array_equal(all_ws, test_ws)
          np.testing.assert_array_equal(all_ids, test_ids)
  
          # non-deterministic
          test_Xs, test_ys, test_ws, test_ids = [], [], [], []
  
          for bidx, (a, b, c, d) in enumerate(
              dataset.iterbatches(
                  batch_size=batch_size,
                  pad_batches=False,
                  deterministic=False,
              )
          ):
              test_Xs.append(a)
              test_ys.append(b)
              test_ws.append(c)
              test_ids.append(d)
  
          # we don't know the order in which the shards are iterated in.
          test_Xs = np.concatenate(test_Xs, axis=0)
          test_ys = np.concatenate(test_ys, axis=0)
          test_ws = np.concatenate(test_ws, axis=0)
          test_ids = np.concatenate(test_ids, axis=0)
  
          if batch_size is None:
              assert bidx == len(shard_sizes) - 1
          else:
              assert bidx == math.ceil(total_size / batch_size) - 1
  
          np.testing.assert_array_equal(
              np.sort(all_Xs, axis=0), np.sort(test_Xs, axis=0)
          )
          np.testing.assert_array_equal(
              np.sort(all_ys, axis=0), np.sort(test_ys, axis=0)
          )
          np.testing.assert_array_equal(
              np.sort(all_ws, axis=0), np.sort(test_ws, axis=0)
          )
          np.testing.assert_array_equal(
              np.sort(all_ids, axis=0), np.sort(test_ids, axis=0)
          )
  
imports: import random
  import math
  import unittest
  import os
  import numpy
  import pytest
  import deepchem
  import pandas
  import tempfile
label_desc: Use image node_id 22 for calling a global function with example usage: test_disk_iterate_batch() without return types