// 把整数 n 格式化成 4 字节的网络字节序
974468
func encodeNetworkByteOrder(orderBytes []byte, n uint32) {
	orderBytes[0] = byte(n >> 24)
	orderBytes[1] = byte(n >> 16)
	orderBytes[2] = byte(n >> 8)
	orderBytes[3] = byte(n)
}
842838
func EncodeNonce(i uint64) BlockNonce {
	var n BlockNonce
	binary.BigEndian.PutUint64(n[:], i)
	return n
}
670933
func Int63n(n int64) int64 {
	mu.Lock()
	res := r.Int63n(n)
	mu.Unlock()
	return res
}
423667
func (c *Consistent) GetN(name string, n int) ([]string, error) {
	c.RLock()
	defer c.RUnlock()

	if len(c.circle) == 0 {
		return nil, ErrEmptyCircle
	}

	if c.count < int64(n) {
		n = int(c.count)
	}

	var (
		key   = c.hashKey(name)
		i     = c.search(key)
		start = i
		res   = make([]string, 0, n)
		elem  = c.circle[c.sortedHashes[i]]
	)

	res = append(res, elem)

	if len(res) == n {
		return res, nil
	}

	for i = start + 1; i != start; i++ {
		if i >= len(c.sortedHashes) {
			i = 0
		}
		elem = c.circle[c.sortedHashes[i]]
		if !sliceContainsMember(res, elem) {
			res = append(res, elem)
		}
		if len(res) == n {
			break
		}
	}

	return res, nil
}
1154950
func DigitsN(n int) string {
	digits := make([]rune, n)
	for i := 0; i < n; i++ {
		digits[i] = numeric[r.Intn(len(numeric))]
	}
	return string(digits)
}
874527
func (ung UniformGenerator) Int64n(n int64) int64 {
	if n <= 0 {
		panic(fmt.Sprintf("Illegal parameter n: %d", n))
	}
	ung.mu.Lock()
	defer ung.mu.Unlock()
	return ung.rd.Int63n(n)
}
896257
func MaxUint8N(v ...uint8) uint8 {
	switch len(v) {
	case 0:
		return 0
	case 1:
		return v[0]
	case 2:
		return MaxUint8(v[0], v[1])
	default:
		l := len(v) / 2
		return MaxUint8N(MaxUint8N(v[:l]...), MaxUint8N(v[l:]...))
	}
}
806574
func (r *Rand) Int63n(n int64) int64 {
	if n <= 0 {
		panic("invalid argument to Int63n")
	}
	if n&(n-1) == 0 { // n is power of two, can mask
		return r.Int63() & (n - 1)
	}
	max := int64((1 << 63) - 1 - (1<<63)%uint64(n))
	v := r.Int63()
	for v > max {
		v = r.Int63()
	}
	return v % n
}
392421
func (ung UniformGenerator) Int32n(n int32) int32 {
	if n <= 0 {
		panic(fmt.Sprintf("Illegal parameter n: %d", n))
	}
	ung.mu.Lock()
	defer ung.mu.Unlock()
	return ung.rd.Int31n(n)
}
544286
func (s *AttributeValue) SetN(v string) *AttributeValue {
	s.N = &v
	return s
}
1051791
func (vn *VecN) Zero(n int) {
	vn.Resize(n)
	for i := range vn.vec {
		vn.vec[i] = 0
	}
}
739303
func (list *List) PopN(n int) []string {
	if n < 1 || n >= list.length {
		return emptySlice()
	}
	if n == 1 {
		return oneSlice(list.Pop())
	}
	pos := list.length - n
	return list.Slice(pos, -1)
}
1324234
func (p *Prefix) NumNodes() *big.Int {
	i := new(big.Int).SetBytes(invert(p.Mask))
	return i.Add(i, big.NewInt(1))
}
1127816
func MinInt32N(v ...int32) int32 {
	switch len(v) {
	case 0:
		return 0
	case 1:
		return v[0]
	case 2:
		return MinInt32(v[0], v[1])
	default:
		l := len(v) / 2
		return MinInt32N(MinInt32N(v[:l]...), MinInt32N(v[l:]...))
	}
}
1337471
func (handle *Context) NewRNN(hiddenSize int, numLayers int, dropout *Dropout, inputMode RNNInputMode, direction DirectionMode, mode RNNMode, algo RNNAlgo, dataType DataType) (retVal *RNN, err error) {
	var internal C.cudnnRNNDescriptor_t
	if err := result(C.cudnnCreateRNNDescriptor(&internal)); err != nil {
		return nil, err
	}

	if err := result(C.cudnnSetRNNDescriptor(handle.internal, internal, C.int(hiddenSize), C.int(numLayers), dropout.internal, inputMode.C(), direction.C(), mode.C(), algo.C(), dataType.C())); err != nil {
		return nil, err
	}

	retVal = &RNN{
		internal: internal,

		hiddenSize:        hiddenSize,
		layers:            numLayers,
		dropoutDescriptor: dropout,
		inputMode:         inputMode,
		directionMode:     direction,
		mode:              mode,
		algo:              algo,
		dataType:          dataType,
		matrixMathType:    DefaultMath,
	}
	runtime.SetFinalizer(retVal, destroyRNN)
	return retVal, nil
}
1272328
func MinUint8N(v ...uint8) uint8 {
	switch len(v) {
	case 0:
		return 0
	case 1:
		return v[0]
	case 2:
		return MinUint8(v[0], v[1])
	default:
		l := len(v) / 2
		return MinUint8N(MinUint8N(v[:l]...), MinUint8N(v[l:]...))
	}
}
91205
func (f *File) NumConns() int {
	f.connsLock.Lock()
	defer f.connsLock.Unlock()

	return len(f.conns)
}