class_docstr: Circular experience replay buffer for `CounterfactualRL` (DDPG). When the buffer is filled, then the oldest
  experience is replaced by the new one (FIFO). The experience batch size is kept constant and inferred when
  the first batch of data is stored. Allowing flexible batch size can generate `tensorflow` warning due to
  the `tf.function` retracing, which can lead to a drop in performance.
class_docstr_tok: ["Circular","experience","replay","buffer","for","`","CounterfactualRL","`","(","DDPG",")",".","When","the","buffer","is","filled",",","then","the","oldest","experience","is","replaced","by","the","new","one","(","FIFO",")",".","The","experience","batch","size","is","kept","constant","and","inferred","when","the","first","batch","of","data","is","stored",".","Allowing","flexible","batch","size","can","generate","`","tensorflow","`","warning","due","to","the","`","tf.function","`","retracing",",","which","can","lead","to","a","drop","in","performance","."]
docstr: Constructor.
  
  Parameters
  ----------
  size
      Dimension of the buffer in batch size. This that the total memory allocated is proportional with the
      `size x batch_size`, where `batch_size` is inferred from the first array to be stored.
code: def __init__(self, size: int = 1000) -> None:
      """
      Constructor.
  
      Parameters
      ----------
      size
          Dimension of the buffer in batch size. This that the total memory allocated is proportional with the
          `size x batch_size`, where `batch_size` is inferred from the first array to be stored.
      """
  
      self.idx = 0  # cursor for the buffer
      self.len = 0  # current length of the buffer
      self.size = size  # buffer's maximum capacity
      self.batch_size = 0  # batch size (inferred during `append`)
      self.C: Optional[np.ndarray] = None
  
imports: import logging
  import os
  from abc import ABC, abstractmethod
  from copy import deepcopy
  from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Tuple, Union, cast
  import numpy
  from tqdm import tqdm
  from alibi.api.defaults import DEFAULT_DATA_CFRL, DEFAULT_META_CFRL
  from alibi.api.interfaces import Explainer, Explanation, FitMixin
  from alibi.explainers.backends.cfrl_base import generate_empty_condition, get_classification_reward, get_hard_distribution, identity_function
  from alibi.utils.frameworks import Framework, has_pytorch, has_tensorflow
label_desc: Use image node_id 1 to create a new ReplayBuffer object  with example: obj = ReplayBuffer(size)