def __init__(
        self,
        observation_space: spaces.Space,
        action_space: spaces.Space,
        epoch_len: int = int(1e3),
        capacity: int = int(1e6),
        n_step: int = 1,
        gamma: float = 0.99,
        history_len: int = 1,
        mode: str = "numpy",
        logdir: str = None,
    ):
        """
        Experience replay buffer for off-policy RL algorithms.

        Args:
            observation_space: space of environment observation
                e.g. (8, ) for vector of floats or (84, 84, 3) for RGB image
            action_space: space of action the agent can take
                e.g. (3, ) for 3-dimensional continuous control
            capacity: replay buffer capacity
            n_step: number of time steps between the current state and the next
                state in TD backup
            gamma: discount factor
            history_len: number of subsequent observations considered a state
        """
        self.epoch_len = epoch_len
        self.observation_space = observation_space
        self.action_space = action_space
        self.history_len = history_len
        self.n_step = n_step
        self.gamma = gamma

        self.length = 0
        self.capacity = capacity
        self.capacity_limit_koef = 2
        self.capacity_limit = int(capacity * self.capacity_limit_koef)

        self._store_lock = mp.Lock()
        self.num_trajectories = 0
        self.num_transitions = 0
        self.pointer = 0
        self._trajectories_lens = []
        self._trajectories_rewards = []

        self.observations = BufferWrapper(
            capacity=self.capacity_limit,
            space=self.observation_space,
            name="observations",
            mode=mode,
            logdir=logdir,
        )
        self.actions = BufferWrapper(
            capacity=self.capacity_limit,
            space=self.action_space,
            name="actions",
            mode=mode,
            logdir=logdir,
        )
        self.rewards = BufferWrapper(
            capacity=self.capacity_limit,
            shape=(),
            dtype=np.float32,
            name="rewards",
            mode=mode,
            logdir=logdir,
        )
        self.dones = BufferWrapper(
            capacity=self.capacity_limit,
            shape=(),
            dtype=np.bool,
            name="dones",
            mode=mode,
            logdir=logdir,
        )

        Experience replay buffer for off-policy RL algorithms.

        Args:
            observation_space: space of environment observation
                e.g. (8, ) for vector of floats or (84, 84, 3) for RGB image
            action_space: space of action the agent can take
                e.g. (3, ) for 3-dimensional continuous control
            capacity: replay buffer capacity
            n_step: number of time steps between the current state and the next
                state in TD backup
            gamma: discount factor
            history_len: number of subsequent observations considered a state
        
examples/catalyst_rl/buffer.py