Fix bug in add_average implementation, also allow for weighted averages.
Fix bug in add_average implementation, also allow for weighted averages.

PiperOrigin-RevId: 318214790

google-research/google-research,google-research/google-research,google-research/google-research,google-research/google-research,google-research/google-research,google-research/google-research,google-research/google-research,google-research/google-research,google-research/google-research,google-research/google-research,google-research/google-research