code: def data_generator(
      X: np.ndarray,
      encoder_preprocessor: Callable,
      predictor: Callable,
      conditional_func: Callable,
      batch_size: int,
      shuffle: bool = True,
      **kwargs,
  ):
      """
      Constructs a `tensorflow` data generator.
  
      Parameters
      ----------
      X
          Array of input instances. The input should NOT be preprocessed as it will be preprocessed when calling
          the `preprocessor` function.
      encoder_preprocessor
          Preprocessor function. This function correspond to the preprocessing steps applied to the encoder/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.
      shuffle
          Whether to shuffle the dataset each epoch. ``True`` by default.
      **kwargs
          Other arguments. Not used.
      """
      return TfCounterfactualRLDataset(
          X=X,
          preprocessor=encoder_preprocessor,
          predictor=predictor,
          conditional_func=conditional_func,
          batch_size=batch_size,
          shuffle=shuffle,
      )
  
imports: import os
  import random
  from typing import Any, List, Dict, Callable, Union, Optional, TYPE_CHECKING
  import numpy
  import tensorflow
  import tensorflow.keras
  from alibi.explainers.backends.cfrl_base import CounterfactualRLDataset
  from alibi.models.tensorflow.actor_critic import Actor, Critic
label_desc: Use image node_id 6 for calling a global function with example usage: data_generator(X, encoder_preprocessor, predictor, conditional_func, batch_size, shuffle) and returns: TfCounterfactualRLDataset