code: def _build_marginal_constraints(self, i, coef, constraint_lam, constraint_l2):
          
  
          composite_C = np.zeros((len(coef), len(coef)))
  
          for slice_ in self._iterate_marginal_coef_slices(i):
              # get the slice of coefficient vector
              coef_slice = coef[slice_]
  
              # build the constraint matrix for that slice
              slice_C = self._terms[i].build_constraints(coef_slice, constraint_lam, constraint_l2)
  
              # now enter it into the composite
              composite_C[tuple(np.meshgrid(slice_, slice_))] = slice_C.A
  
          return sp.sparse.csc_matrix(composite_C)
docs: builds a constraint matrix for a marginal term in the tensor term
  
          takes a tensor's coef vector, and slices it into pieces corresponding
          to term i, then builds a constraint matrix for each piece of the coef vector,
          and assembles them into a composite constraint matrix
  
          Parameters
          ----------
          i : int,
              index of the marginal term for which to build a constraint matrix
  
          coefs : array-like containing the coefficients of the tensor term
  
          constraint_lam : float,
              penalty to impose on the constraint.
  
              typically this is a very large number.
  
          constraint_l2 : float,
              loading to improve the numerical conditioning of the constraint
              matrix.
  
              typically this is a very small number.
  
          Returns
          -------
          C : sparse CSC matrix containing the model constraints in quadratic form