docstr: Predict the classification labels of the input dataset. This is performed in batches.
  
  Parameters
  ----------
  X
      Input to be classified.
  predictor
      Prediction function.
  batch_size
      Maximum batch size to be used during each inference step.
  
  Returns
  -------
  Classification labels.
docstr_tok: ["Predict","the","classification","labels","of","the","input","dataset",".","This","is","performed","in","batches",".","Parameters","--","--","--","--","--","X","Input","to","be","classified",".","predictor","Prediction","function",".","batch_size","Maximum","batch","size","to","be","used","during","each","inference","step",".","Returns","--","--","--","-","Classification","labels","."]
code: def predict_batches(
      X: np.ndarray, predictor: Callable, batch_size: int
  ) -> np.ndarray:
      """
      Predict the classification labels of the input dataset. This is performed in batches.
  
      Parameters
      ----------
      X
          Input to be classified.
      predictor
          Prediction function.
      batch_size
          Maximum batch size to be used during each inference step.
  
      Returns
      -------
      Classification labels.
      """
      n_minibatch = int(np.ceil(X.shape[0] / batch_size))
      Y_m = []
  
      for i in range(n_minibatch):
          istart, istop = i * batch_size, min(
              (i + 1) * batch_size, X.shape[0]
          )
          preds = predictor(X[istart:istop])
  
          # Check if the prediction task is classification. We do this by checking if the last dimension of
          # the prediction is grater than 1. Note that this makes the assumption that the regression task has only
          # a single output (multi-output regression exists too). To be addressed in the future.
          if len(preds.shape) == 2 and preds.shape[-1] > 1:
              preds = get_hard_distribution(preds)
  
          # Add predictions to the model predictions buffer.
          Y_m.append(preds)
  
      return np.concatenate(Y_m, axis=0)
  
file_path: alibi/alibi/explainers/backends/cfrl_base.py
imports: import numpy
  from typing import Callable, Any, Optional
  from abc import ABC, abstractmethod
label_desc: Use image node_id 1 for calling the CounterfactualRLDataset obj's underlying member method code with example usage: obj.predict_batches(X, predictor, batch_size) and returns: np