Forward computation.
555940
def hybrid_forward(self, F, x, sampled_values, label, w_all, b_all):
        """"""
        sampled_candidates, expected_count_sampled, expected_count_true = sampled_values
        # (num_sampled, in_unit)
        w_sampled = w_all.slice(begin=(0, 0), end=(self._num_sampled, None))
        w_true = w_all.slice(begin=(self._num_sampled, 0), end=(None, None))
        b_sampled = b_all.slice(begin=(0,), end=(self._num_sampled,))
        b_true = b_all.slice(begin=(self._num_sampled,), end=(None,))
        # true pred
        # (batch_size, 1)
        x = x.reshape((-1, self._in_unit))
        pred_true = (w_true * x).sum(axis=1) + b_true
        # samples pred
        # (batch_size, num_sampled)
        b_sampled = F.reshape(b_sampled, (-1,))
        pred_sampled = F.FullyConnected(x, weight=w_sampled, bias=b_sampled,
                                        num_hidden=self._num_sampled)

        # remove accidental hits
        if self._remove_accidental_hits:
            label_vec = F.reshape(label, (-1, 1))
            sample_vec = F.reshape(sampled_candidates, (1, -1))
            mask = F.broadcast_equal(label_vec, sample_vec) * -1e37
            pred_sampled = pred_sampled + mask

        # subtract log(q)
        expected_count_sampled = F.reshape(expected_count_sampled,
                                           shape=(1, self._num_sampled))
        expected_count_true = expected_count_true.reshape((-1,))
        pred_true = pred_true - F.log(expected_count_true)
        pred_true = pred_true.reshape((-1, 1))
        pred_sampled = F.broadcast_sub(pred_sampled, F.log(expected_count_sampled))

        # pred and new_labels
        # (batch_size, 1+num_sampled)
        pred = F.concat(pred_true, pred_sampled, dim=1)
        if self._sparse_label:
            new_label = F.zeros_like(label)
        else:
            label_vec = F.reshape(label, (-1, 1))
            new_label_true = F.ones_like(label_vec)
            new_label_sampled = F.zeros_like(pred_sampled)
            new_label = F.Concat(new_label_true, new_label_sampled, dim=1)
        return pred, new_label
108949
def mulmod(computation: BaseComputation) -> None:
    
    left, right, mod = computation.stack_pop(num_items=3, type_hint=constants.UINT256)

    if mod == 0:
        result = 0
    else:
        result = (left * right) % mod
    computation.stack_push(result)
571465
def compute(self, bottomUpInput, enableLearn, computeInfOutput=None):
    """"""

    if enableLearn:
      self.learn(bottomUpInput)
    else:
      self.infer(bottomUpInput)
683990
def forward(self, x, mask):
        """"""
        all_layers = []
        for layer in self.layers:
            x = layer(x, mask)
            if self.return_all_layers:
                all_layers.append(x)

        if self.return_all_layers:
            all_layers[-1] = self.norm(all_layers[-1])
            return all_layers
        return self.norm(x)
307513
def compute(self):
        """"""
        self._compute_window_size()
        smooth = []
        residual = []

        x, y = self.x, self.y

        # step through x and y data with a window window_size wide.
        self._update_values_in_window()
        self._update_mean_in_window()
        self._update_variance_in_window()
        for i, (xi, yi) in enumerate(zip(x, y)):
            if ((i - self._neighbors_on_each_side) > 0.0 and
                    (i + self._neighbors_on_each_side) < len(x)):
                self._advance_window()
            smooth_here = self._compute_smooth_during_construction(xi)
            residual_here = self._compute_cross_validated_residual_here(xi, yi, smooth_here)
            smooth.append(smooth_here)
            residual.append(residual_here)

        self._store_unsorted_results(smooth, residual)
714193
private void ssMergeForward(int PA, int first, int middle, int last, int buf,
                                int depth) {
        // PA, first, middle, last, buf are pointers to SA
        int a, b, c, bufend;// pointers to SA
        int t, r;

        bufend = buf + (middle - first) - 1;
        ssBlockSwap(buf, first, middle - first);

        for (t = SA[a = first], b = buf, c = middle; ; ) {
            r = ssCompare(PA + SA[b], PA + SA[c], depth);
            if (r < 0) {
                do {
                    SA[a++] = SA[b];
                    if (bufend <= b) {
                        SA[bufend] = t;
                        return;
                    }
                    SA[b++] = SA[a];
                }
                while (SA[b] < 0);
            } else if (r > 0) {
                do {
                    SA[a++] = SA[c];
                    SA[c++] = SA[a];
                    if (last <= c) {
                        while (b < bufend) {
                            SA[a++] = SA[b];
                            SA[b++] = SA[a];
                        }
                        SA[a] = SA[b];
                        SA[b] = t;
                        return;
                    }
                }
                while (SA[c] < 0);
            } else {
                SA[c] = ~SA[c];
                do {
                    SA[a++] = SA[b];
                    if (bufend <= b) {
                        SA[bufend] = t;
                        return;
                    }
                    SA[b++] = SA[a];
                }
                while (SA[b] < 0);

                do {
                    SA[a++] = SA[c];
                    SA[c++] = SA[a];
                    if (last <= c) {
                        while (b < bufend) {
                            SA[a++] = SA[b];
                            SA[b++] = SA[a];
                        }
                        SA[a] = SA[b];
                        SA[b] = t;
                        return;
                    }
                }
                while (SA[c] < 0);
            }
        }

    }
304739
def forwards(self, orm):
        ""
        for node in orm.FileNode.objects.all():
            node.save()
440556
def _precompute(self, tree):
        
        d = {}
        for n in tree.preorder_internal_node_iter():
            d[n] = namedtuple('NodeDist', ['dist_from_root', 'edges_from_root'])
            if n.parent_node:
                d[n].dist_from_root = d[n.parent_node].dist_from_root + n.edge_length
                d[n].edges_from_root = d[n.parent_node].edges_from_root + 1
            else:
                d[n].dist_from_root = 0.0
                d[n].edges_from_root = 0
        return d
418953
function computeForwardSlotSegs(levels) {
	var i, level;
	var j, seg;
	var k;

	for (i=0; i<levels.length; i++) {
		level = levels[i];

		for (j=0; j<level.length; j++) {
			seg = level[j];

			seg.forwardSegs = [];
			for (k=i+1; k<levels.length; k++) {
				computeSlotSegCollisions(seg, levels[k], seg.forwardSegs);
			}
		}
	}
}
1224138
def forward(self, X):
        
        return self.W(X).sum(dim=1) + self.b
292576
def forward(self, x: torch.Tensor, sublayer: Callable[[torch.Tensor], torch.Tensor]) -> torch.Tensor:
        """"""
        return x + self.dropout(sublayer(self.norm(x)))
581100
public static void Forward(double[] data) {
        double[] result = new double[data.length];

        for (int k = 0; k < result.length; k++) {
            double sum = 0;
            for (int n = 0; n < data.length; n++) {
                double theta = ((2.0 * Math.PI) / data.length) * k * n;
                sum += data[n] * cas(theta);
            }
            result[k] = (1.0 / Math.sqrt(data.length)) * sum;
        }

        for (int i = 0; i < result.length; i++) {
            data[i] = result[i];
        }

    }
117438
private void ssMergeBackward(int PA, int first, int middle, int last, int buf,
                                 int depth) {
        // PA, first, middle, last, buf are pointers in SA
        int p1, p2;// pointers in SA
        int a, b, c, bufend;// pointers in SA
        int t, r, x;

        bufend = buf + (last - middle) - 1;
        ssBlockSwap(buf, middle, last - middle);

        x = 0;
        if (SA[bufend] < 0) {
            p1 = PA + ~SA[bufend];
            x |= 1;
        } else {
            p1 = PA + SA[bufend];
        }
        if (SA[middle - 1] < 0) {
            p2 = PA + ~SA[middle - 1];
            x |= 2;
        } else {
            p2 = PA + SA[middle - 1];
        }
        for (t = SA[a = last - 1], b = bufend, c = middle - 1; ; ) {
            r = ssCompare(p1, p2, depth);
            if (0 < r) {
                if ((x & 1) != 0) {
                    do {
                        SA[a--] = SA[b];
                        SA[b--] = SA[a];
                    }
                    while (SA[b] < 0);
                    x ^= 1;
                }
                SA[a--] = SA[b];
                if (b <= buf) {
                    SA[buf] = t;
                    break;
                }
                SA[b--] = SA[a];
                if (SA[b] < 0) {
                    p1 = PA + ~SA[b];
                    x |= 1;
                } else {
                    p1 = PA + SA[b];
                }
            } else if (r < 0) {
                if ((x & 2) != 0) {
                    do {
                        SA[a--] = SA[c];
                        SA[c--] = SA[a];
                    }
                    while (SA[c] < 0);
                    x ^= 2;
                }
                SA[a--] = SA[c];
                SA[c--] = SA[a];
                if (c < first) {
                    while (buf < b) {
                        SA[a--] = SA[b];
                        SA[b--] = SA[a];
                    }
                    SA[a] = SA[b];
                    SA[b] = t;
                    break;
                }
                if (SA[c] < 0) {
                    p2 = PA + ~SA[c];
                    x |= 2;
                } else {
                    p2 = PA + SA[c];
                }
            } else {
                if ((x & 1) != 0) {
                    do {
                        SA[a--] = SA[b];
                        SA[b--] = SA[a];
                    }
                    while (SA[b] < 0);
                    x ^= 1;
                }
                SA[a--] = ~SA[b];
                if (b <= buf) {
                    SA[buf] = t;
                    break;
                }
                SA[b--] = SA[a];
                if ((x & 2) != 0) {
                    do {
                        SA[a--] = SA[c];
                        SA[c--] = SA[a];
                    }
                    while (SA[c] < 0);
                    x ^= 2;
                }
                SA[a--] = SA[c];
                SA[c--] = SA[a];
                if (c < first) {
                    while (buf < b) {
                        SA[a--] = SA[b];
                        SA[b--] = SA[a];
                    }
                    SA[a] = SA[b];
                    SA[b] = t;
                    break;
                }
                if (SA[b] < 0) {
                    p1 = PA + ~SA[b];
                    x |= 1;
                } else {
                    p1 = PA + SA[b];
                }
                if (SA[c] < 0) {
                    p2 = PA + ~SA[c];
                    x |= 2;
                } else {
                    p2 = PA + SA[c];
                }
            }
        }
    }
755602
def hybrid_forward(self, F, a, b):
        
        # a.shape = [B, L1, H]
        # b.shape = [B, L2, H]
        # extract features
        tilde_a = self.f(a)  # shape = [B, L1, H]
        tilde_b = self.f(b)  # shape = [B, L2, H]
        # attention
        # e.shape = [B, L1, L2]
        e = F.batch_dot(tilde_a, tilde_b, transpose_b=True)
        # beta: b align to a, [B, L1, H]
        beta = F.batch_dot(e.softmax(), tilde_b)
        # alpha: a align to b, [B, L2, H]
        alpha = F.batch_dot(e.transpose([0, 2, 1]).softmax(), tilde_a)
        # compare
        feature1 = self.g(F.concat(tilde_a, beta, dim=2))
        feature2 = self.g(F.concat(tilde_b, alpha, dim=2))
        feature1 = feature1.sum(axis=1)
        feature2 = feature2.sum(axis=1)
        yhat = self.h(F.concat(feature1, feature2, dim=1))
        return yhat
810946
@Override
    public Tensor forward() {
        Tensor x = modInX.getOutput();
        y = new Tensor(x); // copy
        y.log();
        return y;
    }
739130
@Override
    public Beliefs forward() {
        // Initialization.
        initForward();
        
        // Message passing.
        loops:
        for (int iter=-1; iter < prm.maxIterations; iter++) {
            List<Object> order = sched.getOrder(iter, fg);
            for (Object item : order) {
                List<Integer> edges = CachingBpSchedule.toEdgeList(fg, item);
                List<?> elems = CachingBpSchedule.toFactorEdgeList(item);
                TapeEntry te = prm.keepTape ? new TapeEntry(item, edges) : null;
                for (Object elem : elems) {
                    if (elem instanceof Integer) {
                        forwardCreateMessage((Integer) elem);
                    } else if (elem instanceof AutodiffGlobalFactor) {
                        forwardGlobalFacToVar((AutodiffGlobalFactor) elem, te);
                    } else {
                        throw new RuntimeException("Unsupported type in schedule: " + elem.getClass());
                    }
                }
                for (Integer edge : edges) {
                    normalizeAndAddToTape(edge, te);
                }
                for (Integer edge : edges) {
                    forwardSendMessage(edge, iter);
                }
                if (prm.keepTape) { tape.add(te); }
                if (isConverged()) {
                    // Stop on convergence: Break out of inner and outer loop.
                    log.trace("Stopping on convergence. Iterations = {}", (iter+1));
                    break loops;
                }
            }
            maybeWriteAllBeliefs(iter);
        }
        
        log.trace("Oscillation rate: {}", ((double) oscillationCount.get() / sendCount.get()));
        
        forwardVarAndFacBeliefs();
        b = new Beliefs(varBeliefs, facBeliefs);
        return b;
    }
717701
def _cdf(self, xloc, dist, base, cache):
        """"""
        return evaluation.evaluate_forward(dist, base**xloc, cache=cache)