code: def _validate_pytorch_dataset(dataset):
      X = dataset.X
      y = dataset.y
      w = dataset.w
      ids = dataset.ids
      n_samples = X.shape[0]
  
      # Test iterating in order.
  
      ds = dataset.make_pytorch_dataset(epochs=2, deterministic=True)
      for i, (iter_X, iter_y, iter_w, iter_id) in enumerate(ds):
          j = i % n_samples
          np.testing.assert_array_equal(X[j, :], iter_X)
          np.testing.assert_array_equal(y[j, :], iter_y)
          np.testing.assert_array_equal(w[j, :], iter_w)
          assert ids[j] == iter_id
      assert i == 2 * n_samples - 1
  
      # Test iterating out of order.
  
      ds = dataset.make_pytorch_dataset(epochs=2, deterministic=False)
      id_to_index = dict((id, i) for i, id in enumerate(ids))
      id_count = dict((id, 0) for id in ids)
      for iter_X, iter_y, iter_w, iter_id in ds:
          j = id_to_index[iter_id]
          np.testing.assert_array_equal(X[j, :], iter_X)
          np.testing.assert_array_equal(y[j, :], iter_y)
          np.testing.assert_array_equal(w[j, :], iter_w)
          id_count[iter_id] += 1
      assert all(id_count[id] == 2 for id in ids)
  
      # Test iterating in batches.
  
      ds = dataset.make_pytorch_dataset(
          epochs=2, deterministic=False, batch_size=7
      )
      id_to_index = dict((id, i) for i, id in enumerate(ids))
      id_count = dict((id, 0) for id in ids)
      for iter_X, iter_y, iter_w, iter_id in ds:
          size = len(iter_id)
          assert size <= 7
          for i in range(size):
              j = id_to_index[iter_id[i]]
              np.testing.assert_array_equal(X[j, :], iter_X[i])
              np.testing.assert_array_equal(y[j, :], iter_y[i])
              np.testing.assert_array_equal(w[j, :], iter_w[i])
              id_count[iter_id[i]] += 1
      assert all(id_count[id] == 2 for id in ids)
  
      # Test iterating with multiple workers.
  
      import torch  # noqa
  
      ds = dataset.make_pytorch_dataset(epochs=2, deterministic=False)
      loader = torch.utils.data.DataLoader(ds, num_workers=3)
      id_count = dict((id, 0) for id in ids)
      for iter_X, iter_y, iter_w, iter_id in loader:
          j = id_to_index[iter_id[0]]
          np.testing.assert_array_equal(X[j, :], iter_X[0])
          np.testing.assert_array_equal(y[j, :], iter_y[0])
          np.testing.assert_array_equal(w[j, :], iter_w[0])
          id_count[iter_id[0]] += 1
      assert all(id_count[id] == 2 for id in ids)
  
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 25 for calling a global function with example usage: _validate_pytorch_dataset(dataset) without return types