neulab/docprompting-conala huggingface dataset:
torch.set_printoptions(precision=None, threshold=None, edgeitems=None, linewidth=None, profile=None, sci_mode=None) [source]
 
Set options for printing. Items shamelessly taken from NumPy  Parameters 
 
precision – Number of digits of precision for floating point output (default = 4). 
threshold – Total number of array elements which trigger summarization rather than full repr (default = 1000). 
edgeitems – Number of array items in summary at beginning and end of each dimension (default = 3). 
linewidth – The number of characters per line for the purpose of inserting line breaks (default = 80). Thresholded matrices will ignore this parameter. 
profile – Sane defaults for pretty printing. Can override with any of the above options. (any one of default, short, full) 
sci_mode – Enable (True) or disable (False) scientific notation. If None (default) is specified, the value is defined by torch._tensor_str._Formatter. This value is automatically chosen by the framework.
torch.set_rng_state(new_state) [source]
 
Sets the random number generator state.  Parameters 
new_state (torch.ByteTensor) – The desired state
torch.sgn(input, *, out=None) → Tensor  
For complex tensors, this function returns a new tensor whose elemants have the same angle as that of the elements of input and absolute value 1. For a non-complex tensor, this function returns the signs of the elements of input (see torch.sign()). outi=0\text{out}_{i} = 0 , if ∣inputi∣==0|{\text{{input}}_i}| == 0  outi=inputi∣inputi∣\text{out}_{i} = \frac{{\text{{input}}_i}}{|{\text{{input}}_i}|} , otherwise  Parameters 
input (Tensor) – the input tensor.  Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> x=torch.tensor([3+4j, 7-24j, 0, 1+2j])
>>> x.sgn()
tensor([0.6000+0.8000j, 0.2800-0.9600j, 0.0000+0.0000j, 0.4472+0.8944j])
torch.sigmoid(input, *, out=None) → Tensor  
Returns a new tensor with the sigmoid of the elements of input.  outi=11+e−inputi\text{out}_{i} = \frac{1}{1 + e^{-\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.9213,  1.0887, -0.8858, -1.7683])
>>> torch.sigmoid(a)
tensor([ 0.7153,  0.7481,  0.2920,  0.1458])
torch.sign(input, *, out=None) → Tensor  
Returns a new tensor with the signs of the elements of input.  outi=sgn⁡(inputi)\text{out}_{i} = \operatorname{sgn}(\text{input}_{i})  
 Parameters 
input (Tensor) – the input tensor.  Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> a = torch.tensor([0.7, -1.2, 0., 2.3])
>>> a
tensor([ 0.7000, -1.2000,  0.0000,  2.3000])
>>> torch.sign(a)
tensor([ 1., -1.,  0.,  1.])
torch.signbit(input, *, out=None) → Tensor  
Tests if each element of input has its sign bit set (is less than zero) or not.  Parameters 
input (Tensor) – the input tensor.  Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> a = torch.tensor([0.7, -1.2, 0., 2.3])
>>> torch.signbit(a)
tensor([ False, True,  False,  False])
torch.sin(input, *, out=None) → Tensor  
Returns a new tensor with the sine of the elements of input.  outi=sin⁡(inputi)\text{out}_{i} = \sin(\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.5461,  0.1347, -2.7266, -0.2746])
>>> torch.sin(a)
tensor([-0.5194,  0.1343, -0.4032, -0.2711])
torch.sinc(input, *, out=None) → Tensor  
Computes the normalized sinc of input.  outi={1,if inputi=0sin⁡(πinputi)/(πinputi),otherwise\text{out}_{i} = \begin{cases} 1, & \text{if}\ \text{input}_{i}=0 \\ \sin(\pi \text{input}_{i}) / (\pi \text{input}_{i}), & \text{otherwise} \end{cases}  
 Parameters 
input (Tensor) – the input tensor.  Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> a = torch.randn(4)
>>> a
tensor([ 0.2252, -0.2948,  1.0267, -1.1566])
>>> torch.sinc(a)
tensor([ 0.9186,  0.8631, -0.0259, -0.1300])
torch.sinh(input, *, out=None) → Tensor  
Returns a new tensor with the hyperbolic sine of the elements of input.  outi=sinh⁡(inputi)\text{out}_{i} = \sinh(\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.5380, -0.8632, -0.1265,  0.9399])
>>> torch.sinh(a)
tensor([ 0.5644, -0.9744, -0.1268,  1.0845])
  Note When input is on the CPU, the implementation of torch.sinh may use the Sleef library, which rounds very large results to infinity or negative infinity. See here for details.
torch.slogdet(input) -> (Tensor, Tensor)  
Calculates the sign and log absolute value of the determinant(s) of a square matrix or batches of square matrices.  Note torch.slogdet() is deprecated. Please use torch.linalg.slogdet() instead.   Note If input has zero determinant, this returns (0, -inf).   Note Backward through slogdet() internally uses SVD results when input is not invertible. In this case, double backward through slogdet() will be unstable in when input doesn’t have distinct singular values. See svd() for details.   Parameters 
input (Tensor) – the input tensor of size (*, n, n) where * is zero or more batch dimensions.  Returns 
A namedtuple (sign, logabsdet) containing the sign of the determinant, and the log value of the absolute determinant.   Example: >>> A = torch.randn(3, 3)
>>> A
tensor([[ 0.0032, -0.2239, -1.1219],
        [-0.6690,  0.1161,  0.4053],
        [-1.6218, -0.9273, -0.0082]])
>>> torch.det(A)
tensor(-0.7576)
>>> torch.logdet(A)
tensor(nan)
>>> torch.slogdet(A)
torch.return_types.slogdet(sign=tensor(-1.), logabsdet=tensor(-0.2776))
torch.smm(input, mat) → Tensor  
Performs a matrix multiplication of the sparse matrix input with the dense matrix mat.  Parameters 
 
input (Tensor) – a sparse matrix to be matrix multiplied 
mat (Tensor) – a dense matrix to be matrix multiplied
torch.solve(input, A, *, out=None) -> (Tensor, Tensor)  
This function returns the solution to the system of linear equations represented by AX=BAX = B  and the LU factorization of A, in order as a namedtuple solution, LU. LU contains L and U factors for LU factorization of A. torch.solve(B, A) can take in 2D inputs B, A or inputs that are batches of 2D matrices. If the inputs are batches, then returns batched outputs solution, LU. Supports real-valued and complex-valued inputs.  Note Irrespective of the original strides, the returned matrices solution and LU will be transposed, i.e. with strides like B.contiguous().transpose(-1, -2).stride() and A.contiguous().transpose(-1, -2).stride() respectively.   Parameters 
 
input (Tensor) – input matrix BB  of size (∗,m,k)(*, m, k)  , where ∗*  is zero or more batch dimensions. 
A (Tensor) – input square matrix of size (∗,m,m)(*, m, m) , where ∗*  is zero or more batch dimensions.   Keyword Arguments 
out ((Tensor, Tensor), optional) – optional output tuple.   Example: >>> A = torch.tensor([[6.80, -2.11,  5.66,  5.97,  8.23],
...                   [-6.05, -3.30,  5.36, -4.44,  1.08],
...                   [-0.45,  2.58, -2.70,  0.27,  9.04],
...                   [8.32,  2.71,  4.35,  -7.17,  2.14],
...                   [-9.67, -5.14, -7.26,  6.08, -6.87]]).t()
>>> B = torch.tensor([[4.02,  6.19, -8.22, -7.57, -3.03],
...                   [-1.56,  4.00, -8.67,  1.75,  2.86],
...                   [9.81, -4.09, -4.57, -8.61,  8.99]]).t()
>>> X, LU = torch.solve(B, A)
>>> torch.dist(B, torch.mm(A, X))
tensor(1.00000e-06 *
       7.0977)

>>> # Batched solver example
>>> A = torch.randn(2, 3, 1, 4, 4)
>>> B = torch.randn(2, 3, 1, 4, 6)
>>> X, LU = torch.solve(B, A)
>>> torch.dist(B, A.matmul(X))
tensor(1.00000e-06 *
   3.6386)
torch.sort(input, dim=-1, descending=False, *, out=None) -> (Tensor, LongTensor)  
Sorts the elements of the input tensor along a given dimension in ascending order by value. If dim is not given, the last dimension of the input is chosen. If descending is True then the elements are sorted in descending order by value. A namedtuple of (values, indices) is returned, where the values are the sorted values and indices are the indices of the elements in the original input tensor.  Parameters 
 
input (Tensor) – the input tensor. 
dim (int, optional) – the dimension to sort along 
descending (bool, optional) – controls the sorting order (ascending or descending)   Keyword Arguments 
out (tuple, optional) – the output tuple of (Tensor, LongTensor) that can be optionally given to be used as output buffers   Example: >>> x = torch.randn(3, 4)
>>> sorted, indices = torch.sort(x)
>>> sorted
tensor([[-0.2162,  0.0608,  0.6719,  2.3332],
        [-0.5793,  0.0061,  0.6058,  0.9497],
        [-0.5071,  0.3343,  0.9553,  1.0960]])
>>> indices
tensor([[ 1,  0,  2,  3],
        [ 3,  1,  0,  2],
        [ 0,  3,  1,  2]])

>>> sorted, indices = torch.sort(x, 0)
>>> sorted
tensor([[-0.5071, -0.2162,  0.6719, -0.5793],
        [ 0.0608,  0.0061,  0.9497,  0.3343],
        [ 0.6058,  0.9553,  1.0960,  2.3332]])
>>> indices
tensor([[ 2,  0,  0,  1],
        [ 0,  1,  1,  2],
        [ 1,  2,  2,  0]])
torch.sparse.addmm(mat, mat1, mat2, beta=1.0, alpha=1.0) [source]
 
This function does exact same thing as torch.addmm() in the forward, except that it supports backward for sparse matrix mat1. mat1 need to have sparse_dim = 2. Note that the gradients of mat1 is a coalesced sparse tensor.  Parameters 
 
mat (Tensor) – a dense matrix to be added 
mat1 (Tensor) – a sparse matrix to be multiplied 
mat2 (Tensor) – a dense matrix to be multiplied 
beta (Number, optional) – multiplier for mat (β\beta ) 
alpha (Number, optional) – multiplier for mat1@mat2mat1 @ mat2  (α\alpha )
torch.sparse.log_softmax(input, dim, dtype=None) [source]
 
Applies a softmax function followed by logarithm. See softmax for more details.  Parameters 
 
input (Tensor) – input 
dim (int) – A dimension along which softmax will be computed. 
dtype (torch.dtype, optional) – the desired data type of returned tensor. If specified, the input tensor is casted to dtype before the operation is performed. This is useful for preventing data type overflows. Default: None
torch.sparse.mm(mat1, mat2) [source]
 
Performs a matrix multiplication of the sparse matrix mat1 and the (sparse or strided) matrix mat2. Similar to torch.mm(), If mat1 is a (n×m)(n \times m)  tensor, mat2 is a (m×p)(m \times p)  tensor, out will be a (n×p)(n \times p)  tensor. mat1 need to have sparse_dim = 2. This function also supports backward for both matrices. Note that the gradients of mat1 is a coalesced sparse tensor.  Parameters 
 
mat1 (SparseTensor) – the first sparse matrix to be multiplied 
mat2 (Tensor) – the second matrix to be multiplied, which could be sparse or dense     Shape:

The format of the output tensor of this function follows: - sparse x sparse -> sparse - sparse x dense -> dense   Example: >>> a = torch.randn(2, 3).to_sparse().requires_grad_(True)
>>> a
tensor(indices=tensor([[0, 0, 0, 1, 1, 1],
                       [0, 1, 2, 0, 1, 2]]),
       values=tensor([ 1.5901,  0.0183, -0.6146,  1.8061, -0.0112,  0.6302]),
       size=(2, 3), nnz=6, layout=torch.sparse_coo, requires_grad=True)

>>> b = torch.randn(3, 2, requires_grad=True)
>>> b
tensor([[-0.6479,  0.7874],
        [-1.2056,  0.5641],
        [-1.1716, -0.9923]], requires_grad=True)

>>> y = torch.sparse.mm(a, b)
>>> y
tensor([[-0.3323,  1.8723],
        [-1.8951,  0.7904]], grad_fn=<SparseAddmmBackward>)
>>> y.sum().backward()
>>> a.grad
tensor(indices=tensor([[0, 0, 0, 1, 1, 1],
                       [0, 1, 2, 0, 1, 2]]),
       values=tensor([ 0.1394, -0.6415, -2.1639,  0.1394, -0.6415, -2.1639]),
       size=(2, 3), nnz=6, layout=torch.sparse_coo)
torch.sparse.softmax(input, dim, dtype=None) [source]
 
Applies a softmax function. Softmax is defined as: Softmax(xi)=exp(xi)∑jexp(xj)\text{Softmax}(x_{i}) = \frac{exp(x_i)}{\sum_j exp(x_j)}  where i,ji, j  run over sparse tensor indices and unspecified entries are ignores. This is equivalent to defining unspecified entries as negative infinity so that exp(xk)=0exp(x_k) = 0  when the entry with index kk  has not specified. It is applied to all slices along dim, and will re-scale them so that the elements lie in the range [0, 1] and sum to 1.  Parameters 
 
input (Tensor) – input 
dim (int) – A dimension along which softmax will be computed. 
dtype (torch.dtype, optional) – the desired data type of returned tensor. If specified, the input tensor is casted to dtype before the operation is performed. This is useful for preventing data type overflows. Default: None
torch.sparse.sum(input, dim=None, dtype=None) [source]
 
Returns the sum of each row of the sparse tensor input in the given dimensions dim. If dim is a list of dimensions, reduce over all of them. When sum over all sparse_dim, this method returns a dense tensor instead of a sparse tensor. All summed dim are squeezed (see torch.squeeze()), resulting an output tensor having dim fewer dimensions than input. During backward, only gradients at nnz locations of input will propagate back. Note that the gradients of input is coalesced.  Parameters 
 
input (Tensor) – the input sparse tensor 
dim (int or tuple of python:ints) – a dimension or a list of dimensions to reduce. Default: reduce over all dims. 
dtype (torch.dtype, optional) – the desired data type of returned Tensor. Default: dtype of input.    Example: >>> nnz = 3
>>> dims = [5, 5, 2, 3]
>>> I = torch.cat([torch.randint(0, dims[0], size=(nnz,)),
                   torch.randint(0, dims[1], size=(nnz,))], 0).reshape(2, nnz)
>>> V = torch.randn(nnz, dims[2], dims[3])
>>> size = torch.Size(dims)
>>> S = torch.sparse_coo_tensor(I, V, size)
>>> S
tensor(indices=tensor([[2, 0, 3],
                       [2, 4, 1]]),
       values=tensor([[[-0.6438, -1.6467,  1.4004],
                       [ 0.3411,  0.0918, -0.2312]],

                      [[ 0.5348,  0.0634, -2.0494],
                       [-0.7125, -1.0646,  2.1844]],

                      [[ 0.1276,  0.1874, -0.6334],
                       [-1.9682, -0.5340,  0.7483]]]),
       size=(5, 5, 2, 3), nnz=3, layout=torch.sparse_coo)

# when sum over only part of sparse_dims, return a sparse tensor
>>> torch.sparse.sum(S, [1, 3])
tensor(indices=tensor([[0, 2, 3]]),
       values=tensor([[-1.4512,  0.4073],
                      [-0.8901,  0.2017],
                      [-0.3183, -1.7539]]),
       size=(5, 2), nnz=3, layout=torch.sparse_coo)

# when sum over all sparse dim, return a dense tensor
# with summed dims squeezed
>>> torch.sparse.sum(S, [0, 1, 3])
tensor([-2.6596, -1.1450])
torch.split(tensor, split_size_or_sections, dim=0) [source]
 
Splits the tensor into chunks. Each chunk is a view of the original tensor. If split_size_or_sections is an integer type, then tensor will be split into equally sized chunks (if possible). Last chunk will be smaller if the tensor size along the given dimension dim is not divisible by split_size. If split_size_or_sections is a list, then tensor will be split into len(split_size_or_sections) chunks with sizes in dim according to split_size_or_sections.  Parameters 
 
tensor (Tensor) – tensor to split. 
split_size_or_sections (int) or (list(int)) – size of a single chunk or list of sizes for each chunk 
dim (int) – dimension along which to split the tensor.     Example::

>>> a = torch.arange(10).reshape(5,2)
>>> a
tensor([[0, 1],
        [2, 3],
        [4, 5],
        [6, 7],
        [8, 9]])
>>> torch.split(a, 2)
(tensor([[0, 1],
         [2, 3]]),
 tensor([[4, 5],
         [6, 7]]),
 tensor([[8, 9]]))
>>> torch.split(a, [1,4])
(tensor([[0, 1]]),
 tensor([[2, 3],
         [4, 5],
         [6, 7],
         [8, 9]]))
torch.sqrt(input, *, out=None) → Tensor  
Returns a new tensor with the square-root of the elements of input.  outi=inputi\text{out}_{i} = \sqrt{\text{input}_{i}}  
 Parameters 
input (Tensor) – the input tensor.  Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> a = torch.randn(4)
>>> a
tensor([-2.0755,  1.0226,  0.0831,  0.4806])
>>> torch.sqrt(a)
tensor([    nan,  1.0112,  0.2883,  0.6933])
torch.square(input, *, out=None) → Tensor  
Returns a new tensor with the square of the elements of input.  Parameters 
input (Tensor) – the input tensor.  Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> a = torch.randn(4)
>>> a
tensor([-2.0755,  1.0226,  0.0831,  0.4806])
>>> torch.square(a)
tensor([ 4.3077,  1.0457,  0.0069,  0.2310])
torch.squeeze(input, dim=None, *, out=None) → Tensor  
Returns a tensor with all the dimensions of input of size 1 removed. For example, if input is of shape: (A×1×B×C×1×D)(A \times 1 \times B \times C \times 1 \times D)  then the out tensor will be of shape: (A×B×C×D)(A \times B \times C \times D) . When dim is given, a squeeze operation is done only in the given dimension. If input is of shape: (A×1×B)(A \times 1 \times B) , squeeze(input, 0) leaves the tensor unchanged, but squeeze(input, 1) will squeeze the tensor to the shape (A×B)(A \times B) .  Note The returned tensor shares the storage with the input tensor, so changing the contents of one will change the contents of the other.   Warning If the tensor has a batch dimension of size 1, then squeeze(input) will also remove the batch dimension, which can lead to unexpected errors.   Parameters 
 
input (Tensor) – the input tensor. 
dim (int, optional) – if given, the input will be squeezed only in this dimension   Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> x = torch.zeros(2, 1, 2, 1, 2)
>>> x.size()
torch.Size([2, 1, 2, 1, 2])
>>> y = torch.squeeze(x)
>>> y.size()
torch.Size([2, 2, 2])
>>> y = torch.squeeze(x, 0)
>>> y.size()
torch.Size([2, 1, 2, 1, 2])
>>> y = torch.squeeze(x, 1)
>>> y.size()
torch.Size([2, 2, 1, 2])
torch.sspaddmm(input, mat1, mat2, *, beta=1, alpha=1, out=None) → Tensor  
Matrix multiplies a sparse tensor mat1 with a dense tensor mat2, then adds the sparse tensor input to the result. Note: This function is equivalent to torch.addmm(), except input and mat1 are sparse.  Parameters 
 
input (Tensor) – a sparse matrix to be added 
mat1 (Tensor) – a sparse matrix to be matrix multiplied 
mat2 (Tensor) – a dense matrix to be matrix multiplied   Keyword Arguments 
 
beta (Number, optional) – multiplier for mat (β\beta ) 
alpha (Number, optional) – multiplier for mat1@mat2mat1 @ mat2  (α\alpha ) 
out (Tensor, optional) – the output tensor.
torch.stack(tensors, dim=0, *, out=None) → Tensor  
Concatenates a sequence of tensors along a new dimension. All tensors need to be of the same size.  Parameters 
 
tensors (sequence of Tensors) – sequence of tensors to concatenate 
dim (int) – dimension to insert. Has to be between 0 and the number of dimensions of concatenated tensors (inclusive)   Keyword Arguments 
out (Tensor, optional) – the output tensor.
torch.std(input, unbiased=True) → Tensor  
Returns the standard-deviation of all elements in the input tensor. If unbiased is False, then the standard-deviation will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.  Parameters 
 
input (Tensor) – the input tensor. 
unbiased (bool) – whether to use the unbiased estimation or not    Example: >>> a = torch.randn(1, 3)
>>> a
tensor([[-0.8166, -1.3802, -0.3560]])
>>> torch.std(a)
tensor(0.5130)
  
torch.std(input, dim, unbiased=True, keepdim=False, *, out=None) → Tensor 
 Returns the standard-deviation of each row of the input tensor in the dimension dim. If dim is a list of dimensions, reduce over all of them. If keepdim is True, the output tensor is of the same size as input except in the dimension(s) dim where it is of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the output tensor having 1 (or len(dim)) fewer dimension(s). If unbiased is False, then the standard-deviation will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.  Parameters 
 
input (Tensor) – the input tensor. 
dim (int or tuple of python:ints) – the dimension or dimensions to reduce. 
unbiased (bool) – whether to use the unbiased estimation or not 
keepdim (bool) – whether the output tensor has dim retained or not.   Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> a = torch.randn(4, 4)
>>> a
tensor([[ 0.2035,  1.2959,  1.8101, -0.4644],
        [ 1.5027, -0.3270,  0.5905,  0.6538],
        [-1.5745,  1.3330, -0.5596, -0.6548],
        [ 0.1264, -0.5080,  1.6420,  0.1992]])
>>> torch.std(a, dim=1)
tensor([ 1.0311,  0.7477,  1.2204,  0.9087])
torch.std_mean(input, unbiased=True) -> (Tensor, Tensor)  
Returns the standard-deviation and mean of all elements in the input tensor. If unbiased is False, then the standard-deviation will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.  Parameters 
 
input (Tensor) – the input tensor. 
unbiased (bool) – whether to use the unbiased estimation or not    Example: >>> a = torch.randn(1, 3)
>>> a
tensor([[0.3364, 0.3591, 0.9462]])
>>> torch.std_mean(a)
(tensor(0.3457), tensor(0.5472))
  
torch.std_mean(input, dim, unbiased=True, keepdim=False) -> (Tensor, Tensor) 
 Returns the standard-deviation and mean of each row of the input tensor in the dimension dim. If dim is a list of dimensions, reduce over all of them. If keepdim is True, the output tensor is of the same size as input except in the dimension(s) dim where it is of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the output tensor having 1 (or len(dim)) fewer dimension(s). If unbiased is False, then the standard-deviation will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.  Parameters 
 
input (Tensor) – the input tensor. 
dim (int or tuple of python:ints) – the dimension or dimensions to reduce. 
unbiased (bool) – whether to use the unbiased estimation or not 
keepdim (bool) – whether the output tensor has dim retained or not.    Example: >>> a = torch.randn(4, 4)
>>> a
tensor([[ 0.5648, -0.5984, -1.2676, -1.4471],
        [ 0.9267,  1.0612,  1.1050, -0.6014],
        [ 0.0154,  1.9301,  0.0125, -1.0904],
        [-1.9711, -0.7748, -1.3840,  0.5067]])
>>> torch.std_mean(a, 1)
(tensor([0.9110, 0.8197, 1.2552, 1.0608]), tensor([-0.6871,  0.6229,  0.2169, -0.9058]))
torch.sub(input, other, *, alpha=1, out=None) → Tensor  
Subtracts other, scaled by alpha, from input.  outi=inputi−alpha×otheri\text{{out}}_i = \text{{input}}_i - \text{{alpha}} \times \text{{other}}_i  
Supports broadcasting to a common shape, type promotion, and integer, float, and complex inputs.  Parameters 
 
input (Tensor) – the input tensor. 
other (Tensor or Scalar) – the tensor or scalar to subtract from input
   Keyword Arguments 
 
alpha (Scalar) – the scalar multiplier for other
 
out (Tensor, optional) – the output tensor.    Example: >>> a = torch.tensor((1, 2))
>>> b = torch.tensor((0, 1))
>>> torch.sub(a, b, alpha=2)
tensor([1, 0])
torch.subtract(input, other, *, alpha=1, out=None) → Tensor  
Alias for torch.sub().