code: def data_labels(self,
                      image,
                      fudged_image,
                      segments,
                      classifier_fn,
                      num_samples,
                      batch_size=10):
          
          n_features = np.unique(segments).shape[0]
          data = self.random_state.randint(0, 2, num_samples * n_features)\
              .reshape((num_samples, n_features))
          labels = []
          data[0, :] = 1
          imgs = []
          for row in data:
              temp = copy.deepcopy(image)
              zeros = np.where(row == 0)[0]
              mask = np.zeros(segments.shape).astype(bool)
              for z in zeros:
                  mask[segments == z] = True
              temp[mask] = fudged_image[mask]
              imgs.append(temp)
              if len(imgs) == batch_size:
                  preds = classifier_fn(np.array(imgs))
                  labels.extend(preds)
                  imgs = []
          if len(imgs) > 0:
              preds = classifier_fn(np.array(imgs))
              labels.extend(preds)
          return data, np.array(labels)
docs: Generates images and predictions in the neighborhood of this image.
  
          Args:
              image: 3d numpy array, the image
              fudged_image: 3d numpy array, image to replace original image when
                  superpixel is turned off
              segments: segmentation of the image
              classifier_fn: function that takes a list of images and returns a
                  matrix of prediction probabilities
              num_samples: size of the neighborhood to learn the linear model
              batch_size: classifier_fn will be called on batches of this size.
  
          Returns:
              A tuple (data, labels), where:
                  data: dense num_samples * num_superpixels
                  labels: prediction probabilities matrix