def add_experiences(self, curr_all_info: AllBrainInfo, next_all_info: AllBrainInfo, take_action_outputs):
        """
        Adds experiences to each agent's experience history.
        :param curr_all_info: Dictionary of all current brains and corresponding BrainInfo.
        :param next_all_info: Dictionary of all current brains and corresponding BrainInfo.
        :param take_action_outputs: The outputs of the Policy's get_action method.
        """
        self.trainer_metrics.start_experience_collection_timer()
        if take_action_outputs:
            self.stats['Policy/Value Estimate'].append(take_action_outputs['value'].mean())
            self.stats['Policy/Entropy'].append(take_action_outputs['entropy'].mean())
            self.stats['Policy/Learning Rate'].append(take_action_outputs['learning_rate'])

        curr_info = curr_all_info[self.brain_name]
        next_info = next_all_info[self.brain_name]

        for agent_id in curr_info.agents:
            self.training_buffer[agent_id].last_brain_info = curr_info
            self.training_buffer[agent_id].last_take_action_outputs = take_action_outputs

        if curr_info.agents != next_info.agents:
            curr_to_use = self.construct_curr_info(next_info)
        else:
            curr_to_use = curr_info

        intrinsic_rewards = self.policy.get_intrinsic_rewards(curr_to_use, next_info)

        for agent_id in next_info.agents:
            stored_info = self.training_buffer[agent_id].last_brain_info
            stored_take_action_outputs = self.training_buffer[agent_id].last_take_action_outputs
            if stored_info is not None:
                idx = stored_info.agents.index(agent_id)
                next_idx = next_info.agents.index(agent_id)
                if not stored_info.local_done[idx]:
                    for i, _ in enumerate(stored_info.visual_observations):
                        self.training_buffer[agent_id]['visual_obs%d' % i].append(
                            stored_info.visual_observations[i][idx])
                        self.training_buffer[agent_id]['next_visual_obs%d' % i].append(
                            next_info.visual_observations[i][next_idx])
                    if self.policy.use_vec_obs:
                        self.training_buffer[agent_id]['vector_obs'].append(stored_info.vector_observations[idx])
                        self.training_buffer[agent_id]['next_vector_in'].append(
                            next_info.vector_observations[next_idx])
                    if self.policy.use_recurrent:
                        if stored_info.memories.shape[1] == 0:
                            stored_info.memories = np.zeros((len(stored_info.agents), self.policy.m_size))
                        self.training_buffer[agent_id]['memory'].append(stored_info.memories[idx])
                    actions = stored_take_action_outputs['action']
                    if self.policy.use_continuous_act:
                        actions_pre = stored_take_action_outputs['pre_action']
                        self.training_buffer[agent_id]['actions_pre'].append(actions_pre[idx])
                        epsilons = stored_take_action_outputs['random_normal_epsilon']
                        self.training_buffer[agent_id]['random_normal_epsilon'].append(
                            epsilons[idx])
                    else:
                        self.training_buffer[agent_id]['action_mask'].append(
                            stored_info.action_masks[idx], padding_value=1)
                    a_dist = stored_take_action_outputs['log_probs']
                    value = stored_take_action_outputs['value']
                    self.training_buffer[agent_id]['actions'].append(actions[idx])
                    self.training_buffer[agent_id]['prev_action'].append(stored_info.previous_vector_actions[idx])
                    self.training_buffer[agent_id]['masks'].append(1.0)
                    if self.use_curiosity:
                        self.training_buffer[agent_id]['rewards'].append(next_info.rewards[next_idx] +
                                                                         intrinsic_rewards[next_idx])
                    else:
                        self.training_buffer[agent_id]['rewards'].append(next_info.rewards[next_idx])
                    self.training_buffer[agent_id]['action_probs'].append(a_dist[idx])
                    self.training_buffer[agent_id]['value_estimates'].append(value[idx][0])
                    if agent_id not in self.cumulative_rewards:
                        self.cumulative_rewards[agent_id] = 0
                    self.cumulative_rewards[agent_id] += next_info.rewards[next_idx]
                    if self.use_curiosity:
                        if agent_id not in self.intrinsic_rewards:
                            self.intrinsic_rewards[agent_id] = 0
                        self.intrinsic_rewards[agent_id] += intrinsic_rewards[next_idx]
                if not next_info.local_done[next_idx]:
                    if agent_id not in self.episode_steps:
                        self.episode_steps[agent_id] = 0
                    self.episode_steps[agent_id] += 1
        self.trainer_metrics.end_experience_collection_timer()