def normreg(self, direct_weighting=True, *args, **kwargs):
        answer_probabilities = self.answer_probabilities(*args, **kwargs)
        q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11 = answer_probabilities
        weights = self.question_weights(answer_probabilities)

        constraints = [q.sum(1, keepdims=True) - 1 for q in answer_probabilities]

        func = lambda x: x**2

        if direct_weighting: # scale the constraints with the weights
            terms = [func(weight * constraint) for weight, constraint in zip(weights, constraints)]
        else:
            terms = [weight * func(constraint) for weight, constraint in zip(weights, constraints)]

        return T.mean(T.concatenate(terms, axis=1))
        
        # means = [T.mean(term) for term in terms] # mean over the minibatch
        # return sum(means)
direct_weighting: if True, the weighting is applied directly to the constraints (before the barrier function).
dataset/ETHPy150Open benanne/kaggle-galaxies/custom.py/ClippedGalaxyOutputLayer.normreg