Sum up the values inside nested python dictionaries if they have the same key

I want to change values in nested python dictionaries if they have the same key. My original dict contains several nested dicts with a different length. If a nested dict has the same key as a previous nested dict, the value of the previous key should be added to the value of the current key. This is basically stacking the values on top of each other. For better understanding:

Moving averaging of Loss during Training in Keras

I am using Keras with TensorFlow to implement a deep neural network. When I plot the loss and number of iterations, there is a significant jump in loss after each epoch. In reality, the loss of each mini-batch should vary from each other, but Keras calculates the moving average of the loss over the mini-batches, that’s why we obtain a smooth curve instead of an arbitrary one. The array of the moving average is reset after each epoch because of which we can observe a jump in the loss.