code: def get_task_test(dataset, n_episodes, n_test, task, log_every_n=50):
      """Gets test set from specified task.
  
      Parameters
      ----------
      dataset: dc.data.Dataset
          Dataset from which to sample.
      n_episodes: int
          Number of episodes to sample test sets for.
      n_test: int
          Number of compounds per test set.
      log_every_n: int, optional
          Prints every log_every_n supports sampled.
      """
      w_task = dataset.w[:, task]
      X_task = dataset.X[w_task != 0]
      y_task = dataset.y[w_task != 0]
      ids_task = dataset.ids[w_task != 0]
      # Now just get weights for this task
      w_task = dataset.w[w_task != 0]
  
      n_samples = len(X_task)
  
      ids = np.random.choice(np.arange(n_samples), (n_episodes, n_test))
  
      tests = []
      for episode in range(n_episodes):
          if episode % log_every_n == 0:
              logger.info("Sampling test %d" % episode)
          inds = ids[episode]
          X_batch = X_task[inds]
          y_batch = np.squeeze(y_task[inds, task])
          w_batch = np.squeeze(w_task[inds, task])
          ids_batch = ids_task[inds]
          tests.append(
              NumpyDataset(X_batch, y_batch, w_batch, ids_batch)
          )
      return tests
  
imports: import logging
  import time
  import numpy
  from deepchem.data import NumpyDataset
label_desc: Use image node_id 5 for calling a global function with example usage: get_task_test(dataset, n_episodes, n_test, task, log_every_n) and returns: tests