def include_episode_loss_dict(loss_dict, episode_loss_dict, number_of_dicts):
    """
    Include the items of episode_loss_dict in loss_dict by creating a new item when the key is not in loss_dict, and
    by additioning the weighted values when the key is already in loss_dict
    Args:
        loss_dict (dict): losses of precedent layers
        episode_loss_dict (dict): losses of current layer
        number_of_dicts (int): how many dicts will be added to loss_dict in one epoch

    Returns:
        dict: updated losses
    """
    new_loss_dict = {}
    for key, value in episode_loss_dict.items():
        if key not in loss_dict:
            new_loss_dict[key] = episode_loss_dict[key] / float(number_of_dicts)
        else:
            new_loss_dict[key] = loss_dict[key] + (episode_loss_dict[key] / float(number_of_dicts))

    return new_loss_dict