'Add batch of episodes to replay buffer.'

def add_to_replay_buffer(self, initial_state, observations, actions, rewards, terminated, pads):

    if (self.replay_buffer is None):
        return
    rewards = np.array(rewards)
    pads = np.array(pads)
    total_rewards = np.sum((rewards * (1 - pads)), axis=0)
    episodes = self.convert_from_batched_episodes(initial_state, observations, actions, rewards, terminated, pads)
    priorities = (total_rewards if (self.prioritize_by == 'reward') else self.cur_step)
    if ((not self.unify_episodes) or self.all_new_ep):
        self.last_idxs = self.replay_buffer.add(episodes, priorities)
    else:
        self.replay_buffer.add(episodes[:1], priorities, self.last_idxs[(-1):])
        if (len(episodes) > 1):
            self.replay_buffer.add(episodes[1:], priorities)
