<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def logp_gradient_contribution(self, calculation_set=None):
 """ Calculates the gradient of the joint log posterior with respect to self. Calculation of the log posterior is restricted to the variables in calculation_set. """

        # NEED some sort of check to see if the log p calculation has recently
        # failed, in which case not to continue

        return self.logp_partial_gradient(self, calculation_set) + builtins.sum(
            [child.logp_partial_gradient(self, calculation_set) for child in self.children])