Backward pass:
dG/dx_i += dG/dy_i dy_i/dx_i = dG/dy_i
dG/dw_i += dG/dy_i dy_i/dw_i = - dG/dy_i
358435
@Override
    public void backward() {
        modInX.getOutputAdj().elemAdd(yAdj);
        modInW.getOutputAdj().elemSubtract(yAdj);
    }
336146
def on_backward_begin(self, last_loss:Rank0Tensor, **kwargs:Any) -> Rank0Tensor:
        ""
        #To avoid gradient underflow, we scale the gradients
        ret_loss = last_loss * self.loss_scale
        return {'last_loss': ret_loss}
989821
def policy_backward(eph, epx, epdlogp, model):
    """"""
    dW2 = np.dot(eph.T, epdlogp).ravel()
    dh = np.outer(epdlogp, model["W2"])
    # Backprop relu.
    dh[eph <= 0] = 0
    dW1 = np.dot(dh.T, epx)
    return {"W1": dW1, "W2": dW2}
1298069
private void backward(final CLClause c, final int ignore) {
        int minlit = 0;
        int minoccs = Integer.MAX_VALUE;
        int litoccs;
        this.stats.steps++;
        for (int i = 0; i < c.lits().size(); i++) {
            final int lit = c.lits().get(i);
            if (lit == ignore) { continue; }
            if (val(lit) < 0) { continue; }
            litoccs = occs(lit).count();
            if (minlit != 0 && minoccs >= litoccs) { continue; }
            minlit = lit;
            minoccs = litoccs;
        }
        if (minoccs >= this.config.bwocclim) { return; }
        assert minlit != 0;
        for (int i = 0; i < c.lits().size(); i++) { mark(c.lits().get(i)); }
        final CLOccs os = occs(minlit);
        for (final CLClause d : os) {
            if (d == c) { continue; }
            int lit;
            int count = this.seen.size();
            int negated = 0;
            this.stats.steps++;
            for (int p = 0; count != 0 && p < d.lits().size(); p++) {
                lit = d.lits().get(p);
                final int m = marked(lit);
                if (m == 0) { continue; }
                assert count > 0;
                count--;
                if (m > 0) { continue; }
                assert m < 0;
                if (negated != 0) {
                    count = Integer.MAX_VALUE;
                    break;
                }
                negated = lit;
            }
            if (count != 0) { continue; }
            if (negated != 0) {
                this.tostrengthen.push(new Pair<>(d, negated));
                this.stats.backwardStrengthened++;
            } else {
                this.stats.backwardSubsumed++;
                dumpClause(d);
            }
        }
        unmark();
    }
333076
def backward(outputs, out_grads=None, retain_graph=False):
    
    assert isinstance(outputs, (list, tuple)), \
        "outputs must be a list or tuple of NDArrays"

    if out_grads is None:
        check_call(_LIB.MXAutogradBackward(
            len(outputs),
            c_handle_array(outputs),
            ctypes.c_void_p(0),
            ctypes.c_int(retain_graph)))
        return

    ograd_handles = []
    for arr in out_grads:
        if arr is not None:
            ograd_handles.append(arr.handle)
        else:
            ograd_handles.append(NDArrayHandle(0))
    assert len(ograd_handles) == len(outputs), \
        "outputs and out_grads must have the same length"

    check_call(_LIB.MXAutogradBackward(
        len(outputs),
        c_handle_array(outputs),
        c_array(NDArrayHandle, ograd_handles),
        ctypes.c_int(retain_graph)))
942549
def d2Sbr_dV2(Cbr, Ybr, V, lam):
    
    nb = len(V)

    diaglam = spdiag(lam)
    diagV = spdiag(V)

    A = Ybr.H * diaglam * Cbr
    B = conj(diagV) * A * diagV
    D = spdiag(mul((A*V), conj(V)))
    E = spdiag(mul((A.T * conj(V)), V))
    F = B + B.T
    G = spdiag(div(matrix(1.0, (nb, 1)), abs(V)))

    Haa = F - D - E
    Hva = 1j * G * (B - B.T - D + E)
    Hav = Hva.T
    Hvv = G * F * G

    return Haa, Hav, Hva, Hvv
1283867
@Override
    public Tensor forward() {
        Tensor x = modInX.getOutput();
        double w_k = modInW.getOutput().getValue(k);
        y = new Tensor(x); // copy
        y.divide(w_k);
        return y;
    }
1182236
def _Backward3_T_Ph(P, h):
    
    hf = _h_3ab(P)
    if h <= hf:
        T = _Backward3a_T_Ph(P, h)
    else:
        T = _Backward3b_T_Ph(P, h)
    return T
668030
@Override
    public void backward() {
        Tensor depAdj = depIn.getOutputAdj();
        int n = depAdj.getDims()[1];
        for (int v=0; v<yAdj.varBeliefs.length; v++) {
            if (yAdj.varBeliefs[v] != null) {
                Var var = y.varBeliefs[v].getVars().get(0);
                if (var instanceof LinkVar) {
                    LinkVar link = (LinkVar) var;
                    int p = link.getParent();
                    int c = link.getChild();
                    int pp = EdgeScores.getTensorParent(p, c);
                    assert p < n && c < n;
                    
                    // Add the adjoint of b(e_{p,c} = True).
                    depAdj.add(yAdj.varBeliefs[v].getValue(LinkVar.TRUE), pp, c);
                    // Add the adjoint of b(e_{p,c} = False)
                    depAdj.subtract(yAdj.varBeliefs[v].getValue(LinkVar.FALSE), pp, c);
                }
            }
        }
    }
233560
@Override
    public void backward() {
        modInX.getOutputAdj().elemAdd(yAdj);
        modInW.getOutputAdj().addValue(k, yAdj.getSum());
    }
862422
def lowpass(cutoff):
  
  R = thub(exp(cutoff - pi), 2)
  G = (R + 1) / 2
  return G * (1 + z ** -1) / (1 + R * z ** -1)
463897
def gradF_t(X, Y, S, M_E, E, m0, rho):
    ''' 
    '''
    n, r = X.shape
    m, r = Y.shape

    XS = np.dot(X, S)
    YS = np.dot(Y, S.T)
    XSY = np.dot(XS, Y.T)

    Qx = np.dot(np.dot(X.T, ((M_E - XSY) * E)), YS) / n
    Qy = np.dot(np.dot(Y.T, ((M_E - XSY) * E).T), XS) / m

    W = np.dot((XSY - M_E) * E, YS) + np.dot(X, Qx) + rho * Gp(X, m0, r)
    Z = np.dot(((XSY - M_E) * E).T, XS) + np.dot(Y, Qy) + rho * Gp(Y, m0, r)

    return W, Z
197173
def backsub_both_sides(L, X, transpose='left'):
    
    if transpose == 'left':
        tmp, _ = dtrtrs(L, X, lower=1, trans=1)
        return dtrtrs(L, tmp.T, lower=1, trans=1)[0].T
    else:
        tmp, _ = dtrtrs(L, X, lower=1, trans=0)
        return dtrtrs(L, tmp.T, lower=1, trans=0)[0].T
971492
function deltaReverse(arg, increment) {
  let newIdx = arg.idx + arg.direction * increment;
  if (newIdx >= arg.values.length) {
    arg.direction *= -1; // Reverse direction
    newIdx = arg.values.length - 2;
  }

  if (newIdx < 0) {
    arg.direction *= -1; // Reverse direction
    newIdx = 1;
  }

  if (newIdx >= 0 && newIdx < arg.values.length) {
    arg.idx = newIdx;
  }

  return true;
}
1045944
def consolidate_reverse_exprs(initial_state):
    
    initial_state.inspect.b('mem_read', when=angr.BP_AFTER, action=_read_consolidate)
    initial_state.inspect.b('reg_read', when=angr.BP_AFTER, action=_read_consolidate)
443711
private static double getSegDistSq(double px, double py, Coordinate a, Coordinate b) {
        double x = a.x;
        double y = a.y;
        double dx = b.x - x;
        double dy = b.y - y;

        if (dx != 0f || dy != 0f) {
            double t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);

            if (t > 1) {
                x = b.x;
                y = b.y;
            } else if (t > 0) {
                x += dx * t;
                y += dy * t;
            }
        }

        dx = px - x;
        dy = py - y;

        return dx * dx + dy * dy;
    }
193206
def backward(self, y):
        
        if self.squeeze:
            y = y[None, :, :]
        ind = np.tril_indices(self.N)
        return np.vstack([y_i[ind] for y_i in y])