<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def reduced_chi_squareds(self, p=None):
 """ Returns the reduced chi squared for each massaged data set. p=None means use the fit results. """

        if len(self._set_xdata)==0 or len(self._set_ydata)==0: return None

        if p is None: p = self.results[0]
        r = self.studentized_residuals(p)
        
        # In case it's not possible to calculate
        if r is None: return

        # calculate the number of points
        N = 0
        for i in range(len(r)): N += len(r[i])

        # degrees of freedom
        dof_per_point = self.degrees_of_freedom()/N

        for n in range(len(r)):
            r[n] = sum(r[n]**2)/(len(r[n])*dof_per_point)

        return r