neulab/docprompting-conala huggingface dataset:
torch.broadcast_shapes(*shapes) → Size [source]
 
Similar to broadcast_tensors() but for shapes. This is equivalent to torch.broadcast_tensors(*map(torch.empty, shapes))[0].shape but avoids the need create to intermediate tensors. This is useful for broadcasting tensors of common batch shape but different rightmost shape, e.g. to broadcast mean vectors with covariance matrices. Example: >>> torch.broadcast_shapes((2,), (3, 1), (1, 1, 1))
torch.Size([1, 3, 2])
  Parameters 
*shapes (torch.Size) – Shapes of tensors.  Returns 
A shape compatible with all input shapes.  Return type 
shape (torch.Size)  Raises 
RuntimeError – If shapes are incompatible.
torch.broadcast_tensors(*tensors) → List of Tensors [source]
 
Broadcasts the given tensors according to Broadcasting semantics.  Parameters 
*tensors – any number of tensors of the same type    Warning More than one element of a broadcasted tensor may refer to a single memory location. As a result, in-place operations (especially ones that are vectorized) may result in incorrect behavior. If you need to write to the tensors, please clone them first.  Example: >>> x = torch.arange(3).view(1, 3)
>>> y = torch.arange(2).view(2, 1)
>>> a, b = torch.broadcast_tensors(x, y)
>>> a.size()
torch.Size([2, 3])
>>> a
tensor([[0, 1, 2],
        [0, 1, 2]])
torch.broadcast_to(input, shape) → Tensor  
Broadcasts input to the shape shape. Equivalent to calling input.expand(shape). See expand() for details.  Parameters 
 
input (Tensor) – the input tensor. 
shape (list, tuple, or torch.Size) – the new shape.    Example: >>> x = torch.tensor([1, 2, 3])
>>> torch.broadcast_to(x, (3, 3))
tensor([[1, 2, 3],
        [1, 2, 3],
        [1, 2, 3]])
torch.bucketize(input, boundaries, *, out_int32=False, right=False, out=None) → Tensor  
Returns the indices of the buckets to which each value in the input belongs, where the boundaries of the buckets are set by boundaries. Return a new tensor with the same size as input. If right is False (default), then the left boundary is closed. More formally, the returned index satisfies the following rules:   
right returned index satisfies   
False boundaries[i-1] < input[m][n]...[l][x] <= boundaries[i]  
True boundaries[i-1] <= input[m][n]...[l][x] < boundaries[i]    Parameters 
 
input (Tensor or Scalar) – N-D tensor or a Scalar containing the search value(s). 
boundaries (Tensor) – 1-D tensor, must contain a monotonically increasing sequence.   Keyword Arguments 
 
out_int32 (bool, optional) – indicate the output data type. torch.int32 if True, torch.int64 otherwise. Default value is False, i.e. default output data type is torch.int64. 
right (bool, optional) – if False, return the first suitable location that is found. If True, return the last such index. If no suitable index found, return 0 for non-numerical value (eg. nan, inf) or the size of boundaries (one pass the last index). In other words, if False, gets the lower bound index for each value in input from boundaries. If True, gets the upper bound index instead. Default value is False. 
out (Tensor, optional) – the output tensor, must be the same size as input if provided.    Example: >>> boundaries = torch.tensor([1, 3, 5, 7, 9])
>>> boundaries
tensor([1, 3, 5, 7, 9])
>>> v = torch.tensor([[3, 6, 9], [3, 6, 9]])
>>> v
tensor([[3, 6, 9],
        [3, 6, 9]])
>>> torch.bucketize(v, boundaries)
tensor([[1, 3, 4],
        [1, 3, 4]])
>>> torch.bucketize(v, boundaries, right=True)
tensor([[2, 3, 5],
        [2, 3, 5]])
torch.can_cast(from, to) → bool  
Determines if a type conversion is allowed under PyTorch casting rules described in the type promotion documentation.  Parameters 
 
from (dpython:type) – The original torch.dtype. 
to (dpython:type) – The target torch.dtype.    Example: >>> torch.can_cast(torch.double, torch.float)
True
>>> torch.can_cast(torch.float, torch.int)
False
torch.cartesian_prod(*tensors) [source]
 
Do cartesian product of the given sequence of tensors. The behavior is similar to python’s itertools.product.  Parameters 
*tensors – any number of 1 dimensional tensors.  Returns 
 A tensor equivalent to converting all the input tensors into lists,

do itertools.product on these lists, and finally convert the resulting list into tensor.    Return type 
Tensor   Example: >>> a = [1, 2, 3]
>>> b = [4, 5]
>>> list(itertools.product(a, b))
[(1, 4), (1, 5), (2, 4), (2, 5), (3, 4), (3, 5)]
>>> tensor_a = torch.tensor(a)
>>> tensor_b = torch.tensor(b)
>>> torch.cartesian_prod(tensor_a, tensor_b)
tensor([[1, 4],
        [1, 5],
        [2, 4],
        [2, 5],
        [3, 4],
        [3, 5]])
torch.cat(tensors, dim=0, *, out=None) → Tensor  
Concatenates the given sequence of seq tensors in the given dimension. All tensors must either have the same shape (except in the concatenating dimension) or be empty. torch.cat() can be seen as an inverse operation for torch.split() and torch.chunk(). torch.cat() can be best understood via examples.  Parameters 
 
tensors (sequence of Tensors) – any python sequence of tensors of the same type. Non-empty tensors provided must have the same shape, except in the cat dimension. 
dim (int, optional) – the dimension over which the tensors are concatenated   Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> x = torch.randn(2, 3)
>>> x
tensor([[ 0.6580, -1.0969, -0.4614],
        [-0.1034, -0.5790,  0.1497]])
>>> torch.cat((x, x, x), 0)
tensor([[ 0.6580, -1.0969, -0.4614],
        [-0.1034, -0.5790,  0.1497],
        [ 0.6580, -1.0969, -0.4614],
        [-0.1034, -0.5790,  0.1497],
        [ 0.6580, -1.0969, -0.4614],
        [-0.1034, -0.5790,  0.1497]])
>>> torch.cat((x, x, x), 1)
tensor([[ 0.6580, -1.0969, -0.4614,  0.6580, -1.0969, -0.4614,  0.6580,
         -1.0969, -0.4614],
        [-0.1034, -0.5790,  0.1497, -0.1034, -0.5790,  0.1497, -0.1034,
         -0.5790,  0.1497]])
torch.cdist(x1, x2, p=2.0, compute_mode='use_mm_for_euclid_dist_if_necessary') [source]
 
Computes batched the p-norm distance between each pair of the two collections of row vectors.  Parameters 
 
x1 (Tensor) – input tensor of shape B×P×MB \times P \times M . 
x2 (Tensor) – input tensor of shape B×R×MB \times R \times M . 
p – p value for the p-norm distance to calculate between each vector pair ∈[0,∞]\in [0, \infty] . 
compute_mode – ‘use_mm_for_euclid_dist_if_necessary’ - will use matrix multiplication approach to calculate euclidean distance (p = 2) if P > 25 or R > 25 ‘use_mm_for_euclid_dist’ - will always use matrix multiplication approach to calculate euclidean distance (p = 2) ‘donot_use_mm_for_euclid_dist’ - will never use matrix multiplication approach to calculate euclidean distance (p = 2) Default: use_mm_for_euclid_dist_if_necessary.    If x1 has shape B×P×MB \times P \times M  and x2 has shape B×R×MB \times R \times M  then the output will have shape B×P×RB \times P \times R . This function is equivalent to scipy.spatial.distance.cdist(input,’minkowski’, p=p) if p∈(0,∞)p \in (0, \infty) . When p=0p = 0  it is equivalent to scipy.spatial.distance.cdist(input, ‘hamming’) * M. When p=∞p = \infty , the closest scipy function is scipy.spatial.distance.cdist(xn, lambda x, y: np.abs(x - y).max()). Example >>> a = torch.tensor([[0.9041,  0.0196], [-0.3108, -2.4423], [-0.4821,  1.059]])
>>> a
tensor([[ 0.9041,  0.0196],
        [-0.3108, -2.4423],
        [-0.4821,  1.0590]])
>>> b = torch.tensor([[-2.1763, -0.4713], [-0.6986,  1.3702]])
>>> b
tensor([[-2.1763, -0.4713],
        [-0.6986,  1.3702]])
>>> torch.cdist(a, b, p=2)
tensor([[3.1193, 2.0959],
        [2.7138, 3.8322],
        [2.2830, 0.3791]])
torch.ceil(input, *, out=None) → Tensor  
Returns a new tensor with the ceil of the elements of input, the smallest integer greater than or equal to each element.  outi=⌈inputi⌉=⌊inputi⌋+1\text{out}_{i} = \left\lceil \text{input}_{i} \right\rceil = \left\lfloor \text{input}_{i} \right\rfloor + 1  
 Parameters 
input (Tensor) – the input tensor.  Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> a = torch.randn(4)
>>> a
tensor([-0.6341, -1.4208, -1.0900,  0.5826])
>>> torch.ceil(a)
tensor([-0., -1., -1.,  1.])
torch.chain_matmul(*matrices) [source]
 
Returns the matrix product of the NN  2-D tensors. This product is efficiently computed using the matrix chain order algorithm which selects the order in which incurs the lowest cost in terms of arithmetic operations ([CLRS]). Note that since this is a function to compute the product, NN  needs to be greater than or equal to 2; if equal to 2 then a trivial matrix-matrix product is returned. If NN  is 1, then this is a no-op - the original matrix is returned as is.  Parameters 
matrices (Tensors...) – a sequence of 2 or more 2-D tensors whose product is to be determined.  Returns 
if the ithi^{th}  tensor was of dimensions pi×pi+1p_{i} \times p_{i + 1} , then the product would be of dimensions p1×pN+1p_{1} \times p_{N + 1} .  Return type 
Tensor   Example: >>> a = torch.randn(3, 4)
>>> b = torch.randn(4, 5)
>>> c = torch.randn(5, 6)
>>> d = torch.randn(6, 7)
>>> torch.chain_matmul(a, b, c, d)
tensor([[ -2.3375,  -3.9790,  -4.1119,  -6.6577,   9.5609, -11.5095,  -3.2614],
        [ 21.4038,   3.3378,  -8.4982,  -5.2457, -10.2561,  -2.4684,   2.7163],
        [ -0.9647,  -5.8917,  -2.3213,  -5.2284,  12.8615, -12.2816,  -2.5095]])
torch.cholesky(input, upper=False, *, out=None) → Tensor  
Computes the Cholesky decomposition of a symmetric positive-definite matrix AA  or for batches of symmetric positive-definite matrices. If upper is True, the returned matrix U is upper-triangular, and the decomposition has the form:  A=UTUA = U^TU 
If upper is False, the returned matrix L is lower-triangular, and the decomposition has the form:  A=LLTA = LL^T 
If upper is True, and AA  is a batch of symmetric positive-definite matrices, then the returned tensor will be composed of upper-triangular Cholesky factors of each of the individual matrices. Similarly, when upper is False, the returned tensor will be composed of lower-triangular Cholesky factors of each of the individual matrices.  Note torch.linalg.cholesky() should be used over torch.cholesky when possible. Note however that torch.linalg.cholesky() does not yet support the upper parameter and instead always returns the lower triangular matrix.   Parameters 
 
input (Tensor) – the input tensor AA  of size (∗,n,n)(*, n, n)  where * is zero or more batch dimensions consisting of symmetric positive-definite matrices. 
upper (bool, optional) – flag that indicates whether to return a upper or lower triangular matrix. Default: False
   Keyword Arguments 
out (Tensor, optional) – the output matrix   Example: >>> a = torch.randn(3, 3)
>>> a = torch.mm(a, a.t()) # make symmetric positive-definite
>>> l = torch.cholesky(a)
>>> a
tensor([[ 2.4112, -0.7486,  1.4551],
        [-0.7486,  1.3544,  0.1294],
        [ 1.4551,  0.1294,  1.6724]])
>>> l
tensor([[ 1.5528,  0.0000,  0.0000],
        [-0.4821,  1.0592,  0.0000],
        [ 0.9371,  0.5487,  0.7023]])
>>> torch.mm(l, l.t())
tensor([[ 2.4112, -0.7486,  1.4551],
        [-0.7486,  1.3544,  0.1294],
        [ 1.4551,  0.1294,  1.6724]])
>>> a = torch.randn(3, 2, 2)
>>> a = torch.matmul(a, a.transpose(-1, -2)) + 1e-03 # make symmetric positive-definite
>>> l = torch.cholesky(a)
>>> z = torch.matmul(l, l.transpose(-1, -2))
>>> torch.max(torch.abs(z - a)) # Max non-zero
tensor(2.3842e-07)
torch.cholesky_inverse(input, upper=False, *, out=None) → Tensor  
Computes the inverse of a symmetric positive-definite matrix AA  using its Cholesky factor uu : returns matrix inv. The inverse is computed using LAPACK routines dpotri and spotri (and the corresponding MAGMA routines). If upper is False, uu  is lower triangular such that the returned tensor is  inv=(uuT)−1inv = (uu^{{T}})^{{-1}}  
If upper is True or not provided, uu  is upper triangular such that the returned tensor is  inv=(uTu)−1inv = (u^T u)^{{-1}}  
 Parameters 
 
input (Tensor) – the input 2-D tensor uu , a upper or lower triangular Cholesky factor 
upper (bool, optional) – whether to return a lower (default) or upper triangular matrix   Keyword Arguments 
out (Tensor, optional) – the output tensor for inv   Example: >>> a = torch.randn(3, 3)
>>> a = torch.mm(a, a.t()) + 1e-05 * torch.eye(3) # make symmetric positive definite
>>> u = torch.cholesky(a)
>>> a
tensor([[  0.9935,  -0.6353,   1.5806],
        [ -0.6353,   0.8769,  -1.7183],
        [  1.5806,  -1.7183,  10.6618]])
>>> torch.cholesky_inverse(u)
tensor([[ 1.9314,  1.2251, -0.0889],
        [ 1.2251,  2.4439,  0.2122],
        [-0.0889,  0.2122,  0.1412]])
>>> a.inverse()
tensor([[ 1.9314,  1.2251, -0.0889],
        [ 1.2251,  2.4439,  0.2122],
        [-0.0889,  0.2122,  0.1412]])
torch.cholesky_solve(input, input2, upper=False, *, out=None) → Tensor  
Solves a linear system of equations with a positive semidefinite matrix to be inverted given its Cholesky factor matrix uu . If upper is False, uu  is and lower triangular and c is returned such that:  c=(uuT)−1bc = (u u^T)^{{-1}} b  
If upper is True or not provided, uu  is upper triangular and c is returned such that:  c=(uTu)−1bc = (u^T u)^{{-1}} b  
torch.cholesky_solve(b, u) can take in 2D inputs b, u or inputs that are batches of 2D matrices. If the inputs are batches, then returns batched outputs c Supports real-valued and complex-valued inputs. For the complex-valued inputs the transpose operator above is the conjugate transpose.  Parameters 
 
input (Tensor) – input matrix bb  of size (∗,m,k)(*, m, k) , where ∗*  is zero or more batch dimensions 
input2 (Tensor) – input matrix uu  of size (∗,m,m)(*, m, m) , where ∗*  is zero of more batch dimensions composed of upper or lower triangular Cholesky factor 
upper (bool, optional) – whether to consider the Cholesky factor as a lower or upper triangular matrix. Default: False.   Keyword Arguments 
out (Tensor, optional) – the output tensor for c   Example: >>> a = torch.randn(3, 3)
>>> a = torch.mm(a, a.t()) # make symmetric positive definite
>>> u = torch.cholesky(a)
>>> a
tensor([[ 0.7747, -1.9549,  1.3086],
        [-1.9549,  6.7546, -5.4114],
        [ 1.3086, -5.4114,  4.8733]])
>>> b = torch.randn(3, 2)
>>> b
tensor([[-0.6355,  0.9891],
        [ 0.1974,  1.4706],
        [-0.4115, -0.6225]])
>>> torch.cholesky_solve(b, u)
tensor([[ -8.1625,  19.6097],
        [ -5.8398,  14.2387],
        [ -4.3771,  10.4173]])
>>> torch.mm(a.inverse(), b)
tensor([[ -8.1626,  19.6097],
        [ -5.8398,  14.2387],
        [ -4.3771,  10.4173]])
torch.chunk(input, chunks, dim=0) → List of Tensors  
Splits a tensor into a specific number of chunks. Each chunk is a view of the input tensor. Last chunk will be smaller if the tensor size along the given dimension dim is not divisible by chunks.  Parameters 
 
input (Tensor) – the tensor to split 
chunks (int) – number of chunks to return 
dim (int) – dimension along which to split the tensor
torch.clamp(input, min, max, *, out=None) → Tensor  
Clamp all elements in input into the range [ min, max ]. Let min_value and max_value be min and max, respectively, this returns:  yi=min⁡(max⁡(xi,min_value),max_value)y_i = \min(\max(x_i, \text{min\_value}), \text{max\_value})  
 Parameters 
 
input (Tensor) – the input tensor. 
min (Number) – lower-bound of the range to be clamped to 
max (Number) – upper-bound of the range to be clamped to   Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> a = torch.randn(4)
>>> a
tensor([-1.7120,  0.1734, -0.0478, -0.0922])
>>> torch.clamp(a, min=-0.5, max=0.5)
tensor([-0.5000,  0.1734, -0.0478, -0.0922])
  
torch.clamp(input, *, min, out=None) → Tensor 
 Clamps all elements in input to be larger or equal min.  Parameters 
input (Tensor) – the input tensor.  Keyword Arguments 
 
min (Number) – minimal value of each element in the output 
out (Tensor, optional) – the output tensor.    Example: >>> a = torch.randn(4)
>>> a
tensor([-0.0299, -2.3184,  2.1593, -0.8883])
>>> torch.clamp(a, min=0.5)
tensor([ 0.5000,  0.5000,  2.1593,  0.5000])
  
torch.clamp(input, *, max, out=None) → Tensor 
 Clamps all elements in input to be smaller or equal max.  Parameters 
input (Tensor) – the input tensor.  Keyword Arguments 
 
max (Number) – maximal value of each element in the output 
out (Tensor, optional) – the output tensor.    Example: >>> a = torch.randn(4)
>>> a
tensor([ 0.7753, -0.4702, -0.4599,  1.1899])
>>> torch.clamp(a, max=0.5)
tensor([ 0.5000, -0.4702, -0.4599,  0.5000])
torch.clip(input, min, max, *, out=None) → Tensor  
Alias for torch.clamp().
torch.clone(input, *, memory_format=torch.preserve_format) → Tensor  
Returns a copy of input.  Note This function is differentiable, so gradients will flow back from the result of this operation to input. To create a tensor without an autograd relationship to input see detach().   Parameters 
input (Tensor) – the input tensor.  Keyword Arguments 
memory_format (torch.memory_format, optional) – the desired memory format of returned tensor. Default: torch.preserve_format.
torch.column_stack(tensors, *, out=None) → Tensor  
Creates a new tensor by horizontally stacking the tensors in tensors. Equivalent to torch.hstack(tensors), except each zero or one dimensional tensor t in tensors is first reshaped into a (t.numel(), 1) column before being stacked horizontally.  Parameters 
tensors (sequence of Tensors) – sequence of tensors to concatenate  Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> a = torch.tensor([1, 2, 3])
>>> b = torch.tensor([4, 5, 6])
>>> torch.column_stack((a, b))
tensor([[1, 4],
    [2, 5],
    [3, 6]])
>>> a = torch.arange(5)
>>> b = torch.arange(10).reshape(5, 2)
>>> torch.column_stack((a, b, b))
tensor([[0, 0, 1, 0, 1],
        [1, 2, 3, 2, 3],
        [2, 4, 5, 4, 5],
        [3, 6, 7, 6, 7],
        [4, 8, 9, 8, 9]])
torch.combinations(input, r=2, with_replacement=False) → seq  
Compute combinations of length rr  of the given tensor. The behavior is similar to python’s itertools.combinations when with_replacement is set to False, and itertools.combinations_with_replacement when with_replacement is set to True.  Parameters 
 
input (Tensor) – 1D vector. 
r (int, optional) – number of elements to combine 
with_replacement (boolean, optional) – whether to allow duplication in combination   Returns 
A tensor equivalent to converting all the input tensors into lists, do itertools.combinations or itertools.combinations_with_replacement on these lists, and finally convert the resulting list into tensor.  Return type 
Tensor   Example: >>> a = [1, 2, 3]
>>> list(itertools.combinations(a, r=2))
[(1, 2), (1, 3), (2, 3)]
>>> list(itertools.combinations(a, r=3))
[(1, 2, 3)]
>>> list(itertools.combinations_with_replacement(a, r=2))
[(1, 1), (1, 2), (1, 3), (2, 2), (2, 3), (3, 3)]
>>> tensor_a = torch.tensor(a)
>>> torch.combinations(tensor_a)
tensor([[1, 2],
        [1, 3],
        [2, 3]])
>>> torch.combinations(tensor_a, r=3)
tensor([[1, 2, 3]])
>>> torch.combinations(tensor_a, with_replacement=True)
tensor([[1, 1],
        [1, 2],
        [1, 3],
        [2, 2],
        [2, 3],
        [3, 3]])
torch.compiled_with_cxx11_abi() [source]
 
Returns whether PyTorch was built with _GLIBCXX_USE_CXX11_ABI=1
torch.complex(real, imag, *, out=None) → Tensor  
Constructs a complex tensor with its real part equal to real and its imaginary part equal to imag.  Parameters 
 
real (Tensor) – The real part of the complex tensor. Must be float or double. 
imag (Tensor) – The imaginary part of the complex tensor. Must be same dtype as real.   Keyword Arguments 
out (Tensor) – If the inputs are torch.float32, must be torch.complex64. If the inputs are torch.float64, must be torch.complex128.    Example::

>>> real = torch.tensor([1, 2], dtype=torch.float32)
>>> imag = torch.tensor([3, 4], dtype=torch.float32)
>>> z = torch.complex(real, imag)
>>> z
tensor([(1.+3.j), (2.+4.j)])
>>> z.dtype
torch.complex64
torch.conj(input, *, out=None) → Tensor  
Computes the element-wise conjugate of the given input tensor. If :attr`input` has a non-complex dtype, this function just returns input.  Warning In the future, torch.conj() may return a non-writeable view for an input of non-complex dtype. It’s recommended that programs not modify the tensor returned by torch.conj() when input is of non-complex dtype to be compatible with this change.   outi=conj(inputi)\text{out}_{i} = conj(\text{input}_{i})  
 Parameters 
input (Tensor) – the input tensor.  Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> torch.conj(torch.tensor([-1 + 1j, -2 + 2j, 3 - 3j]))
tensor([-1 - 1j, -2 - 2j, 3 + 3j])
torch.copysign(input, other, *, out=None) → Tensor  
Create a new floating-point tensor with the magnitude of input and the sign of other, elementwise.  outi={−∣inputi∣ifotheri≤−0.0∣inputi∣ifotheri≥0.0\text{out}_{i} = \begin{cases} -|\text{input}_{i}| & \text{if} \text{other}_{i} \leq -0.0 \\ |\text{input}_{i}| & \text{if} \text{other}_{i} \geq 0.0 \\ \end{cases}  
Supports broadcasting to a common shape, and integer and float inputs.  Parameters 
 
input (Tensor) – magnitudes. 
other (Tensor or Number) – contains value(s) whose signbit(s) are applied to the magnitudes in input.   Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> a = torch.randn(5)
>>> a
tensor([-1.2557, -0.0026, -0.5387,  0.4740, -0.9244])
>>> torch.copysign(a, 1)
tensor([1.2557, 0.0026, 0.5387, 0.4740, 0.9244])
>>> a = torch.randn(4, 4)
>>> a
tensor([[ 0.7079,  0.2778, -1.0249,  0.5719],
        [-0.0059, -0.2600, -0.4475, -1.3948],
        [ 0.3667, -0.9567, -2.5757, -0.1751],
        [ 0.2046, -0.0742,  0.2998, -0.1054]])
>>> b = torch.randn(4)
tensor([ 0.2373,  0.3120,  0.3190, -1.1128])
>>> torch.copysign(a, b)
tensor([[ 0.7079,  0.2778,  1.0249, -0.5719],
        [ 0.0059,  0.2600,  0.4475, -1.3948],
        [ 0.3667,  0.9567,  2.5757, -0.1751],
        [ 0.2046,  0.0742,  0.2998, -0.1054]])
torch.cos(input, *, out=None) → Tensor  
Returns a new tensor with the cosine of the elements of input.  outi=cos⁡(inputi)\text{out}_{i} = \cos(\text{input}_{i})  
 Parameters 
input (Tensor) – the input tensor.  Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> a = torch.randn(4)
>>> a
tensor([ 1.4309,  1.2706, -0.8562,  0.9796])
>>> torch.cos(a)
tensor([ 0.1395,  0.2957,  0.6553,  0.5574])
torch.cosh(input, *, out=None) → Tensor  
Returns a new tensor with the hyperbolic cosine of the elements of input.  outi=cosh⁡(inputi)\text{out}_{i} = \cosh(\text{input}_{i})  
 Parameters 
input (Tensor) – the input tensor.  Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> a = torch.randn(4)
>>> a
tensor([ 0.1632,  1.1835, -0.6979, -0.7325])
>>> torch.cosh(a)
tensor([ 1.0133,  1.7860,  1.2536,  1.2805])
  Note When input is on the CPU, the implementation of torch.cosh may use the Sleef library, which rounds very large results to infinity or negative infinity. See here for details.
torch.count_nonzero(input, dim=None) → Tensor  
Counts the number of non-zero values in the tensor input along the given dim. If no dim is specified then all non-zeros in the tensor are counted.  Parameters 
 
input (Tensor) – the input tensor. 
dim (int or tuple of python:ints, optional) – Dim or tuple of dims along which to count non-zeros.    Example: >>> x = torch.zeros(3,3)
>>> x[torch.randn(3,3) > 0.5] = 1
>>> x
tensor([[0., 1., 1.],
        [0., 0., 0.],
        [0., 0., 1.]])
>>> torch.count_nonzero(x)
tensor(3)
>>> torch.count_nonzero(x, dim=0)
tensor([0, 1, 2])