code: def __iter__(self):
      n_samples = self.numpy_dataset._X.shape[0]
      worker_info = torch.utils.data.get_worker_info()
      if worker_info is None:
          first_sample = 0
          last_sample = n_samples
      else:
          first_sample = (
              worker_info.id * n_samples // worker_info.num_workers
          )
          last_sample = (
              (worker_info.id + 1)
              * n_samples
              // worker_info.num_workers
          )
      for epoch in range(self.epochs):
          if self.deterministic:
              order = first_sample + np.arange(
                  last_sample - first_sample
              )
          else:
              # Ensure that every worker will pick the same random order for each epoch.
              random = np.random.RandomState(epoch)
              order = random.permutation(n_samples)[
                  first_sample:last_sample
              ]
          if self.batch_size is None:
              for i in order:
                  yield (
                      self.numpy_dataset._X[i],
                      self.numpy_dataset._y[i],
                      self.numpy_dataset._w[i],
                      self.numpy_dataset._ids[i],
                  )
          else:
              for i in range(0, len(order), self.batch_size):
                  indices = order[i : i + self.batch_size]
                  yield (
                      self.numpy_dataset._X[indices],
                      self.numpy_dataset._y[indices],
                      self.numpy_dataset._w[indices],
                      self.numpy_dataset._ids[indices],
                  )
  
file_path: deepchem/deepchem/data/pytorch_datasets.py
imports: import numpy
  import torch
  import torch.distributed
  from deepchem.data.datasets import NumpyDataset, DiskDataset, ImageDataset
  from typing import Optional
label_desc: Use image node_id 2 for calling the _TorchNumpyDataset obj's underlying member method code with example usage: obj.__iter__() without return types