<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def func(self, p):
 """ The function that gets passed to the optimizers. """

        self._set_stochastics(p)
        try:
            return -1. * self.logp
        except ZeroProbability:
            return Inf