<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_partial_gradient(self, variable, calculation_set=None):
 """ Calculates the partial gradient of the posterior of self with respect to variable. Returns zero if self is not in calculation_set. """

        if (calculation_set is None) or (self in calculation_set):

            if not datatypes.is_continuous(variable):
                return zeros(shape(variable.value))

            if variable is self:
                try:
                    gradient_func = self._logp_partial_gradients['value']

                except KeyError:
                    raise NotImplementedError(
                        repr(
                            self) +
                        " has no gradient function for 'value'")

                gradient = np.reshape(
                    gradient_func.get(
                    ),
                    np.shape(
                        variable.value))
            else:
                gradient = builtins.sum(
                    [self._pgradient(variable,
                                     parameter,
                                     value) for parameter,
                     value in six.iteritems(self.parents)])

            return gradient
        else:
            return 0