<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sum(self, weights=None):
 """ return the sum of weights of each object """

        if weights is None:
            weights = self.data.weights
        return utils.bincount(self.labels, weights, self.N)