// BatchNormalizationBackward performs the backward BatchNormalization layer computation.
505077
func (co *Context) BatchNormalizationBackward(mode BatchNormMode, alphaDataDiff float64, betaDataDiff float64, alphaParamDiff float64, betaParamDiff float64, xDesc *TensorDescriptor, x Memory, dyDesc *TensorDescriptor, dy Memory, dxDesc *TensorDescriptor, dx Memory, dBnScaleBiasDesc *TensorDescriptor, bnScale Memory, dBnScaleResult Memory, dBnBiasResult Memory, epsilon float64, savedMean Memory, savedInvVariance Memory) error {
	var alphaDataDiffC, betaDataDiffC, alphaParamDiffC, betaParamDiffC unsafe.Pointer
	switch xDesc.dataType {
	case Float, Half:
		var alphaDataDiffF, betaDataDiffF, alphaParamDiffF, betaParamDiffF C.float
		alphaDataDiffF = C.float(float32(alphaDataDiff))
		betaDataDiffF = C.float(float32(betaDataDiff))
		alphaParamDiffF = C.float(float32(alphaParamDiff))
		betaParamDiffF = C.float(float32(betaParamDiff))
		alphaDataDiffC = unsafe.Pointer(&alphaDataDiffF)
		betaDataDiffC = unsafe.Pointer(&betaDataDiffF)
		alphaParamDiffC = unsafe.Pointer(&alphaParamDiffF)
		betaParamDiffC = unsafe.Pointer(&betaParamDiffF)
	case Double:
		var alphaDataDiffF, betaDataDiffF, alphaParamDiffF, betaParamDiffF C.double
		alphaDataDiffF = C.double(alphaDataDiff)
		betaDataDiffF = C.double(betaDataDiff)
		alphaParamDiffF = C.double(alphaParamDiff)
		betaParamDiffF = C.double(betaParamDiff)
		alphaDataDiffC = unsafe.Pointer(&alphaDataDiffF)
		betaDataDiffC = unsafe.Pointer(&betaDataDiffF)
		alphaParamDiffC = unsafe.Pointer(&alphaParamDiffF)
		betaParamDiffC = unsafe.Pointer(&betaParamDiffF)
	default:
		return errors.Errorf("Unsupported data type: %v", xDesc.dataType)
	}
	// call cudnnBatchNormalizationBackward
	return result(C.cudnnBatchNormalizationBackward(co.internal, mode.C(), alphaDataDiffC, betaDataDiffC, alphaParamDiffC, betaParamDiffC, xDesc.internal, x.Pointer(), dyDesc.internal, dy.Pointer(), dxDesc.internal, dx.Pointer(), dBnScaleBiasDesc.internal, bnScale.Pointer(), dBnScaleResult.Pointer(), dBnBiasResult.Pointer(), C.double(epsilon), savedMean.Pointer(), savedInvVariance.Pointer()))
}
1240511
func appendBatchBySize(b []batchKeys, region RegionVerID, keys [][]byte, sizeFn func([]byte) int, limit int) []batchKeys {
	var start, end int
	for start = 0; start < len(keys); start = end {
		var size int
		for end = start; end < len(keys) && size < limit; end++ {
			size += sizeFn(keys[end])
		}
		b = append(b, batchKeys{
			region: region,
			keys:   keys[start:end],
		})
	}
	return b
}
367239
func createSecondsNormalized(seconds int) (vector []float64) {
	for index := 0; index < seconds; index++ {
		temp := float64(index) / float64(seconds-1)
		vector = append(vector, temp)
	}
	return
}
1366116
func NewRBForwarder(config Config) *RBForwarder {
	produces := make(chan *utils.Message, config.QueueSize)
	retries := make(chan *utils.Message, config.QueueSize)
	reports := make(chan *utils.Message, config.QueueSize)

	f := &RBForwarder{
		working: 1,
		p:       newPipeline(produces, retries, reports),
		r: newReporter(
			config.Retries,
			config.Backoff,
			reports,
			retries,
		),
	}

	fields := logrus.Fields{
		"retries":      config.Retries,
		"backoff_time": config.Backoff,
		"queue_size":   config.QueueSize,
	}

	Logger.WithFields(fields).Debug("Initialized rB Forwarder")

	return f
}
612685
func (r *Render) backward(from, n int) int {
	return r.move(from, from-n)
}
704562
func (d *DefaultMetricCollector) FallbackSuccesses() *rolling.Number {
	d.mutex.RLock()
	defer d.mutex.RUnlock()
	return d.fallbackSuccesses
}
1235418
func (nn *FeedForward) Train(patterns [][][]float64, iterations int, lRate, mFactor float64, debug bool) []float64 {
	errors := make([]float64, iterations)

	for i := 0; i < iterations; i++ {
		var e float64
		for _, p := range patterns {
			nn.Update(p[0])

			tmp := nn.BackPropagate(p[1], lRate, mFactor)
			e += tmp
		}

		errors[i] = e

		if debug && i%1000 == 0 {
			fmt.Println(i, e)
		}
	}

	return errors
}
1278521
func (b *buffer) backward() (start bool, err error) {
	if b.pos == b.promptLen {
		return true, nil
	}
	b.pos--

	// If position is on the same line.
	if _, col := b.pos2xy(b.pos); col != 0 {
		if _, err = term.Output.Write(CursorBackward); err != nil {
			return false, outputError(err.Error())
		}
	} else {
		if _, err = term.Output.Write(CursorUp); err != nil {
			return false, outputError(err.Error())
		}
		if _, err = fmt.Fprintf(term.Output, "\033[%dC", b.columns); err != nil {
			return false, outputError(err.Error())
		}
	}
	return
}
1023422
func (w *VT100Writer) CursorForward(n int) {
	if n == 0 {
		return
	} else if n < 0 {
		w.CursorBackward(-n)
		return
	}
	s := strconv.Itoa(n)
	w.WriteRaw([]byte{0x1b, '['})
	w.WriteRaw([]byte(s))
	w.WriteRaw([]byte{'C'})
	return
}
632457
func pastBackoffLimitOnFailure(job *batch.Job, pods []*v1.Pod) bool {
	if job.Spec.Template.Spec.RestartPolicy != v1.RestartPolicyOnFailure {
		return false
	}
	result := int32(0)
	for i := range pods {
		po := pods[i]
		if po.Status.Phase != v1.PodRunning {
			continue
		}
		for j := range po.Status.InitContainerStatuses {
			stat := po.Status.InitContainerStatuses[j]
			result += stat.RestartCount
		}
		for j := range po.Status.ContainerStatuses {
			stat := po.Status.ContainerStatuses[j]
			result += stat.RestartCount
		}
	}
	if *job.Spec.BackoffLimit == 0 {
		return result > 0
	}
	return result >= *job.Spec.BackoffLimit
}
661165
func GetTransformFeedbackVarying(program uint32, index uint32, bufSize int32, length *int32, size *int32, xtype *uint32, name *uint8) {
	C.glowGetTransformFeedbackVarying(gpGetTransformFeedbackVarying, (C.GLuint)(program), (C.GLuint)(index), (C.GLsizei)(bufSize), (*C.GLsizei)(unsafe.Pointer(length)), (*C.GLsizei)(unsafe.Pointer(size)), (*C.GLenum)(unsafe.Pointer(xtype)), (*C.GLchar)(unsafe.Pointer(name)))
}
1075502
func LinearBackoff(i int) time.Duration {
	return time.Duration(i) * time.Second
}
831436
func (r *RecordCompletion) RollForward(c context.Context) (muts []tumble.Mutation, err error) {
	bdg := &model.BackDepGroup{Dependee: *r.For}
	if err = ds.Get(c, bdg); err != nil && err != ds.ErrNoSuchEntity {
		return
	}

	needProp := make([]*model.BackDep, 0, completionLimit)

	q := (ds.NewQuery("BackDep").
		Ancestor(ds.KeyForObj(c, bdg)).
		Eq("Propagated", false).
		Limit(completionLimit))

	if err = ds.GetAll(c, q, &needProp); err != nil {
		return
	}

	if len(needProp) > 0 {
		muts = make([]tumble.Mutation, len(needProp))

		for i, bdep := range needProp {
			bdep.Propagated = true
			muts[i] = &AckFwdDep{bdep.Edge()}
		}

		if len(needProp) == completionLimit {
			// Append ourself if there might be more to do!
			muts = append(muts, r)
		}

		if err = ds.Put(c, needProp); err != nil {
			return
		}
	}

	if !bdg.AttemptFinished {
		bdg.AttemptFinished = true
		if err = ds.Put(c, bdg); err != nil {
			return
		}
	}

	return
}
1048037
func CopyBatch(dst BatchWriter, src Reader, batchSize int) (cnt int, err error) {
	if batchSize <= 0 {
		batchSize = DefaultBatch
	}
	buf := make([]Quad, batchSize)
	bsrc, ok := src.(BatchReader)
	if !ok {
		bsrc = batchReader{src}
	}
	var n int
	for err == nil {
		n, err = bsrc.ReadQuads(buf)
		if err != nil && err != io.EOF {
			return
		}
		eof := err == io.EOF
		n, err = dst.WriteQuads(buf[:n])
		cnt += n
		if eof {
			break
		}
	}
	return
}
521883
func (db *DB) LTrimBack(key []byte, trimSize int32) (int32, error) {
	return db.ltrim(key, trimSize, listTailSeq)
}
352118
func backtrace(err error, t *builtins.CapturedStacktrace) string {
	return t.String() + "Error: " + err.Error()
}
1371422
func (b *BackOff) NextBackOff() time.Duration {
	if b.GetElapsedTime() >= b.MinJobInterval {
		b.Reset()
	}
	return b.ExponentialBackOff.NextBackOff()
}