code: def get_task_support(
      dataset, n_episodes, n_pos, n_neg, task, log_every_n=50
  ):
      """Generates one support set purely for specified task.
  
      Parameters
      ----------
      datasets: dc.data.Dataset
          Dataset from which supports are sampled.
      n_episodes: int
          Number of episodes for which supports have to be sampled from this task.
      n_pos: int
          Number of positive samples in support.
      n_neg: int
          Number of negative samples in support.
      task: int
          Index of current task.
      log_every_n: int, optional
          Prints every log_every_n supports sampled.
  
      Returns
      -------
      list
          List of NumpyDatasets, each of which is a support set.
      """
      y_task = dataset.y[:, task]
      w_task = dataset.w[:, task]
  
      # Split data into pos and neg lists.
      pos_mols = np.where(np.logical_and(y_task == 1, w_task != 0))[0]
      neg_mols = np.where(np.logical_and(y_task == 0, w_task != 0))[0]
  
      supports = []
      for episode in range(n_episodes):
          if episode % log_every_n == 0:
              logger.info("Sampling support %d" % episode)
          # No replacement allowed for supports
          pos_ids = np.random.choice(
              len(pos_mols), (n_pos,), replace=False
          )
          neg_ids = np.random.choice(
              len(neg_mols), (n_neg,), replace=False
          )
          pos_inds, neg_inds = pos_mols[pos_ids], neg_mols[neg_ids]
          # Handle one-d vs. non one-d feature matrices
          one_dimensional_features = len(dataset.X.shape) == 1
          if not one_dimensional_features:
              X = np.vstack([dataset.X[pos_inds], dataset.X[neg_inds]])
          else:
              X = np.concatenate(
                  [dataset.X[pos_inds], dataset.X[neg_inds]]
              )
          y = np.expand_dims(
              np.concatenate(
                  [dataset.y[pos_inds, task], dataset.y[neg_inds, task]]
              ),
              1,
          )
          w = np.expand_dims(
              np.concatenate(
                  [dataset.w[pos_inds, task], dataset.w[neg_inds, task]]
              ),
              1,
          )
          ids = np.concatenate(
              [dataset.ids[pos_inds], dataset.ids[neg_inds]]
          )
          supports.append(NumpyDataset(X, y, w, ids))
      return supports
  
imports: import logging
  import time
  import numpy
  from deepchem.data import NumpyDataset
label_desc: Use image node_id 8 for calling a global function with example usage: get_task_support(dataset, n_episodes, n_pos, n_neg, task, log_every_n) and returns: supports