def remove(self, elem):
        """Remove a requirement.

        :param elem: a string or :class:`Requirement` instance.
        """
        if isinstance(elem, text_type):
            for requirement in self:
                if requirement.package == elem:
                    return super(Requirements, self).remove(requirement)
        return super(Requirements, self).remove(elem)
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)]