def test_add_already_added(self):
        prio_set_list = event._PrioritizedSetList()
        obj = object()
        prio_set_list.add(0, obj)

        with pytest.raises(ValueError) as excinfo:
            prio_set_list.add(0, obj)
        excinfo.match(r"has already been added")

        with pytest.raises(ValueError) as excinfo:
            prio_set_list.add(1, obj)
        excinfo.match(r"has already been added")
def _acc_grads(g_sum, g_w, g):
  """Accumulate gradients in g, weighted by g_w."""
  return [g_sum_i + g_w * g_i for g_sum_i, g_i in zip(g_sum, g)]