class_docstr: Pytorch backend datasets. 
class_docstr_tok: ["Pytorch","backend","datasets","."]
docstr: Constructor.
  
  Parameters
  ----------
  X
      Array of input instances. The input should NOT be preprocessed as it will be preprocessed when calling
      the `preprocessor` function.
  preprocessor
      Preprocessor function. This function correspond to the preprocessing steps applied to
      the auto-encoder model.
  predictor
      Prediction function. The classifier function should expect the input in the original format and preprocess
      it internally in the `predictor` if necessary.
  conditional_func
      Conditional function generator. Given an preprocessed input array, the functions generates a conditional
      array.
  batch_size
      Dimension of the batch used during training. The same batch size is used to infer the classification
      labels of the input dataset.
docstr_tok: ["Constructor",".","Parameters","--","--","--","--","--","X","Array","of","input","instances",".","The","input","should","NOT","be","preprocessed","as","it","will","be","preprocessed","when","calling","the","`","preprocessor","`","function",".","preprocessor","Preprocessor","function",".","This","function","correspond","to","the","preprocessing","steps","applied","to","the","auto-encoder","model",".","predictor","Prediction","function",".","The","classifier","function","should","expect","the","input","in","the","original","format","and","preprocess","it","internally","in","the","`","predictor","`","if","necessary",".","conditional_func","Conditional","function","generator",".","Given","an","preprocessed","input","array",",","the","functions","generates","a","conditional","array",".","batch_size","Dimension","of","the","batch","used","during","training",".","The","same","batch","size","is","used","to","infer","the","classification","labels","of","the","input","dataset","."]
code: def __init__(
      self,
      X: np.ndarray,
      preprocessor: Callable,
      predictor: Callable,
      conditional_func: Callable,
      batch_size: int,
  ) -> None:
      """
      Constructor.
  
      Parameters
      ----------
      X
          Array of input instances. The input should NOT be preprocessed as it will be preprocessed when calling
          the `preprocessor` function.
      preprocessor
          Preprocessor function. This function correspond to the preprocessing steps applied to
          the auto-encoder model.
      predictor
          Prediction function. The classifier function should expect the input in the original format and preprocess
          it internally in the `predictor` if necessary.
      conditional_func
          Conditional function generator. Given an preprocessed input array, the functions generates a conditional
          array.
      batch_size
          Dimension of the batch used during training. The same batch size is used to infer the classification
          labels of the input dataset.
      """
      super().__init__()
  
      self.X = X
      self.preprocessor = preprocessor
      self.predictor = predictor
      self.conditional_func = conditional_func
      self.batch_size = batch_size
  
      # Infer the labels of the input dataset. This is performed in batches.
      self.Y_m = self.predict_batches(
          X=self.X, predictor=self.predictor, batch_size=self.batch_size
      )
  
      # Define number of classes for classification & minimum and maximum labels for regression
      if self.Y_m.shape[1] > 1:
          self.num_classes = self.Y_m.shape[1]
      else:
          self.min_m = np.min(self.Y_m)
          self.max_m = np.max(self.Y_m)
  
      # Preprocess the input data.
      self.X = self.preprocessor(self.X)
  
imports: import os
  import random
  from typing import List, Dict, Callable, Union, Optional, TYPE_CHECKING
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.utils.data import DataLoader, Dataset
  from alibi.explainers.backends.cfrl_base import CounterfactualRLDataset
  from alibi.models.pytorch.actor_critic import Actor, Critic
label_desc: Use image node_id 1 to create a new PtCounterfactualRLDataset object from inherited base classes: CounterfactualRLDataset, Dataset with example: obj = PtCounterfactualRLDataset(X, preprocessor, predictor, conditional_func, batch_size)