code: private static void weightAdjoint(final Hypergraph graph, final Hyperpotential w, 
              final Algebra s, final Scores scores, final HyperedgeDoubleFn lambda, final boolean backOutside) {
          final double[] alpha = scores.alpha;
          final double[] beta = scores.beta;
          final double[] alphaAdj = scores.alphaAdj;
          final double[] betaAdj = scores.betaAdj;
          
          graph.applyTopoSort(new HyperedgeFn() {
              
              @Override
              public void apply(Hyperedge e) {
                  // \adj{w_e} += \adj{\beta_{H(e)} * \prod_{j \in T(e)} \beta_j
                  int i = e.getHeadNode().getId();
                  double prod = betaAdj[i];
                  for (Hypernode jNode : e.getTailNodes()) {
                      int j = jNode.getId();
                      prod = s.times(prod, beta[j]);
                  }
                  double w_e = prod;
                  
                  if (backOutside) {
                      // \adj{w_e} += \adj{\alpha_j} * \alpha_{H(e)} * \prod_{k \in T(e) : k \neq j} \beta_k
                      for (Hypernode jNode : e.getTailNodes()) {
                          int j = jNode.getId();                
                          prod = s.times(alphaAdj[j], alpha[i]);
                          for (Hypernode kNode : e.getTailNodes()) {
                              int k = kNode.getId();
                              if (k == j) { continue; }
                              prod = s.times(prod, beta[k]);
                          }
                          w_e = s.plus(w_e, prod);
                      }
                  }
                  
                  lambda.apply(e, w_e);
              }
              
          });
      }
docs: Computes the adjoints of the hyperedge weights.
  INPUT: scores.alpha, scores.beta, scores.alphaAdj, scores.betaAdj.
  OUTPUT: The adjoints of the weights.
  
  @param graph The hypergraph
  @param w The potential function.
  @param s The semiring.
  @param scores Input struct.
  @param lambda Function to call with the edge and the edge adjoint.