neulab/docprompting-conala huggingface dataset:
torch.mean(input) → Tensor  
Returns the mean value of all elements in the input tensor.  Parameters 
input (Tensor) – the input tensor.   Example: >>> a = torch.randn(1, 3)
>>> a
tensor([[ 0.2294, -0.5481,  1.3288]])
>>> torch.mean(a)
tensor(0.3367)
  
torch.mean(input, dim, keepdim=False, *, out=None) → Tensor 
 Returns the mean value of each row of the input tensor in the given 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).  Parameters 
 
input (Tensor) – the input tensor. 
dim (int or tuple of python:ints) – the dimension or dimensions to reduce. 
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.3841,  0.6320,  0.4254, -0.7384],
        [-0.9644,  1.0131, -0.6549, -1.4279],
        [-0.2951, -1.3350, -0.7694,  0.5600],
        [ 1.0842, -0.9580,  0.3623,  0.2343]])
>>> torch.mean(a, 1)
tensor([-0.0163, -0.5085, -0.4599,  0.1807])
>>> torch.mean(a, 1, True)
tensor([[-0.0163],
        [-0.5085],
        [-0.4599],
        [ 0.1807]])
torch.median(input) → Tensor  
Returns the median of the values in input.  Note The median is not unique for input tensors with an even number of elements. In this case the lower of the two medians is returned. To compute the mean of both medians, use torch.quantile() with q=0.5 instead.   Warning This function produces deterministic (sub)gradients unlike median(dim=0)   Parameters 
input (Tensor) – the input tensor.   Example: >>> a = torch.randn(1, 3)
>>> a
tensor([[ 1.5219, -1.5212,  0.2202]])
>>> torch.median(a)
tensor(0.2202)
  
torch.median(input, dim=-1, keepdim=False, *, out=None) -> (Tensor, LongTensor) 
 Returns a namedtuple (values, indices) where values contains the median of each row of input in the dimension dim, and indices contains the index of the median values found in the dimension dim. By default, dim is the last dimension of the input tensor. If keepdim is True, the output tensors are of the same size as input except in the dimension dim where they are of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the outputs tensor having 1 fewer dimension than input.  Note The median is not unique for input tensors with an even number of elements in the dimension dim. In this case the lower of the two medians is returned. To compute the mean of both medians in input, use torch.quantile() with q=0.5 instead.   Warning indices does not necessarily contain the first occurrence of each median value found, unless it is unique. The exact implementation details are device-specific. Do not expect the same result when run on CPU and GPU in general. For the same reason do not expect the gradients to be deterministic.   Parameters 
 
input (Tensor) – the input tensor. 
dim (int) – the dimension to reduce. 
keepdim (bool) – whether the output tensor has dim retained or not.   Keyword Arguments 
out ((Tensor, Tensor), optional) – The first tensor will be populated with the median values and the second tensor, which must have dtype long, with their indices in the dimension dim of input.   Example: >>> a = torch.randn(4, 5)
>>> a
tensor([[ 0.2505, -0.3982, -0.9948,  0.3518, -1.3131],
        [ 0.3180, -0.6993,  1.0436,  0.0438,  0.2270],
        [-0.2751,  0.7303,  0.2192,  0.3321,  0.2488],
        [ 1.0778, -1.9510,  0.7048,  0.4742, -0.7125]])
>>> torch.median(a, 1)
torch.return_types.median(values=tensor([-0.3982,  0.2270,  0.2488,  0.4742]), indices=tensor([1, 4, 4, 3]))
torch.meshgrid(*tensors) [source]
 
Take NN  tensors, each of which can be either scalar or 1-dimensional vector, and create NN  N-dimensional grids, where the ii  th grid is defined by expanding the ii  th input over dimensions defined by other inputs.  Parameters 
tensors (list of Tensor) – list of scalars or 1 dimensional tensors. Scalars will be treated as tensors of size (1,)(1,)  automatically  Returns 
If the input has kk  tensors of size (N1,),(N2,),…,(Nk,)(N_1,), (N_2,), \ldots , (N_k,) , then the output would also have kk  tensors, where all tensors are of size (N1,N2,…,Nk)(N_1, N_2, \ldots , N_k) .  Return type 
seq (sequence of Tensors)   Example: >>> x = torch.tensor([1, 2, 3])
>>> y = torch.tensor([4, 5, 6])
>>> grid_x, grid_y = torch.meshgrid(x, y)
>>> grid_x
tensor([[1, 1, 1],
        [2, 2, 2],
        [3, 3, 3]])
>>> grid_y
tensor([[4, 5, 6],
        [4, 5, 6],
        [4, 5, 6]])
torch.min(input) → Tensor  
Returns the minimum value of all elements in the input tensor.  Warning This function produces deterministic (sub)gradients unlike min(dim=0)   Parameters 
input (Tensor) – the input tensor.   Example: >>> a = torch.randn(1, 3)
>>> a
tensor([[ 0.6750,  1.0857,  1.7197]])
>>> torch.min(a)
tensor(0.6750)
  
torch.min(input, dim, keepdim=False, *, out=None) -> (Tensor, LongTensor) 
 Returns a namedtuple (values, indices) where values is the minimum value of each row of the input tensor in the given dimension dim. And indices is the index location of each minimum value found (argmin). If keepdim is True, the output tensors are of the same size as input except in the dimension dim where they are of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the output tensors having 1 fewer dimension than input.  Note If there are multiple minimal values in a reduced row then the indices of the first minimal value are returned.   Parameters 
 
input (Tensor) – the input tensor. 
dim (int) – the dimension to reduce. 
keepdim (bool) – whether the output tensor has dim retained or not.   Keyword Arguments 
out (tuple, optional) – the tuple of two output tensors (min, min_indices)   Example: >>> a = torch.randn(4, 4)
>>> a
tensor([[-0.6248,  1.1334, -1.1899, -0.2803],
        [-1.4644, -0.2635, -0.3651,  0.6134],
        [ 0.2457,  0.0384,  1.0128,  0.7015],
        [-0.1153,  2.9849,  2.1458,  0.5788]])
>>> torch.min(a, 1)
torch.return_types.min(values=tensor([-1.1899, -1.4644,  0.0384, -0.1153]), indices=tensor([2, 0, 1, 0]))
  
torch.min(input, other, *, out=None) → Tensor 
 See torch.minimum().
torch.minimum(input, other, *, out=None) → Tensor  
Computes the element-wise minimum of input and other.  Note If one of the elements being compared is a NaN, then that element is returned. minimum() is not supported for tensors with complex dtypes.   Parameters 
 
input (Tensor) – the input tensor. 
other (Tensor) – the second input tensor   Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> a = torch.tensor((1, 2, -1))
>>> b = torch.tensor((3, 0, 4))
>>> torch.minimum(a, b)
tensor([1, 0, -1])
torch.mm(input, mat2, *, out=None) → Tensor  
Performs a matrix multiplication of the matrices input and mat2. If input 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.  Note This function does not broadcast. For broadcasting matrix products, see torch.matmul().  Supports strided and sparse 2-D tensors as inputs, autograd with respect to strided inputs. This operator supports TensorFloat32.  Parameters 
 
input (Tensor) – the first matrix to be matrix multiplied 
mat2 (Tensor) – the second matrix to be matrix multiplied   Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> mat1 = torch.randn(2, 3)
>>> mat2 = torch.randn(3, 3)
>>> torch.mm(mat1, mat2)
tensor([[ 0.4851,  0.5037, -0.3633],
        [-0.0760, -3.6705,  2.4784]])
torch.mode(input, dim=-1, keepdim=False, *, out=None) -> (Tensor, LongTensor)  
Returns a namedtuple (values, indices) where values is the mode value of each row of the input tensor in the given dimension dim, i.e. a value which appears most often in that row, and indices is the index location of each mode value found. By default, dim is the last dimension of the input tensor. If keepdim is True, the output tensors are of the same size as input except in the dimension dim where they are of size 1. Otherwise, dim is squeezed (see torch.squeeze()), resulting in the output tensors having 1 fewer dimension than input.  Note This function is not defined for torch.cuda.Tensor yet.   Parameters 
 
input (Tensor) – the input tensor. 
dim (int) – the dimension to reduce. 
keepdim (bool) – whether the output tensor has dim retained or not.   Keyword Arguments 
out (tuple, optional) – the result tuple of two output tensors (values, indices)   Example: >>> a = torch.randint(10, (5,))
>>> a
tensor([6, 5, 1, 0, 2])
>>> b = a + (torch.randn(50, 1) * 5).long()
>>> torch.mode(b, 0)
torch.return_types.mode(values=tensor([6, 5, 1, 0, 2]), indices=tensor([2, 2, 2, 2, 2]))
torch.moveaxis(input, source, destination) → Tensor  
Alias for torch.movedim(). This function is equivalent to NumPy’s moveaxis function. Examples: >>> t = torch.randn(3,2,1)
>>> t
tensor([[[-0.3362],
        [-0.8437]],

        [[-0.9627],
        [ 0.1727]],

        [[ 0.5173],
        [-0.1398]]])
>>> torch.moveaxis(t, 1, 0).shape
torch.Size([2, 3, 1])
>>> torch.moveaxis(t, 1, 0)
tensor([[[-0.3362],
        [-0.9627],
        [ 0.5173]],

        [[-0.8437],
        [ 0.1727],
        [-0.1398]]])
>>> torch.moveaxis(t, (1, 2), (0, 1)).shape
torch.Size([2, 1, 3])
>>> torch.moveaxis(t, (1, 2), (0, 1))
tensor([[[-0.3362, -0.9627,  0.5173]],

        [[-0.8437,  0.1727, -0.1398]]])
torch.movedim(input, source, destination) → Tensor  
Moves the dimension(s) of input at the position(s) in source to the position(s) in destination. Other dimensions of input that are not explicitly moved remain in their original order and appear at the positions not specified in destination.  Parameters 
 
input (Tensor) – the input tensor. 
source (int or tuple of python:ints) – Original positions of the dims to move. These must be unique. 
destination (int or tuple of python:ints) – Destination positions for each of the original dims. These must also be unique.    Examples: >>> t = torch.randn(3,2,1)
>>> t
tensor([[[-0.3362],
        [-0.8437]],

        [[-0.9627],
        [ 0.1727]],

        [[ 0.5173],
        [-0.1398]]])
>>> torch.movedim(t, 1, 0).shape
torch.Size([2, 3, 1])
>>> torch.movedim(t, 1, 0)
tensor([[[-0.3362],
        [-0.9627],
        [ 0.5173]],

        [[-0.8437],
        [ 0.1727],
        [-0.1398]]])
>>> torch.movedim(t, (1, 2), (0, 1)).shape
torch.Size([2, 1, 3])
>>> torch.movedim(t, (1, 2), (0, 1))
tensor([[[-0.3362, -0.9627,  0.5173]],

        [[-0.8437,  0.1727, -0.1398]]])
torch.msort(input, *, out=None) → Tensor  
Sorts the elements of the input tensor along its first dimension in ascending order by value.  Note torch.msort(t) is equivalent to torch.sort(t, dim=0)[0]. See also torch.sort().   Parameters 
input (Tensor) – the input tensor.  Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> t = torch.randn(3, 4)
>>> t
tensor([[-0.1321,  0.4370, -1.2631, -1.1289],
        [-2.0527, -1.1250,  0.2275,  0.3077],
        [-0.0881, -0.1259, -0.5495,  1.0284]])
>>> torch.msort(t)
tensor([[-2.0527, -1.1250, -1.2631, -1.1289],
        [-0.1321, -0.1259, -0.5495,  0.3077],
        [-0.0881,  0.4370,  0.2275,  1.0284]])
torch.mul(input, other, *, out=None)  
Multiplies each element of the input input with the scalar other and returns a new resulting tensor.  outi=other×inputi\text{out}_i = \text{other} \times \text{input}_i  
If input is of type FloatTensor or DoubleTensor, other should be a real number, otherwise it should be an integer  Parameters 
 
{input} –  
other (Number) – the number to be multiplied to each element of input
   Keyword Arguments 
{out} –    Example: >>> a = torch.randn(3)
>>> a
tensor([ 0.2015, -0.4255,  2.6087])
>>> torch.mul(a, 100)
tensor([  20.1494,  -42.5491,  260.8663])
  
torch.mul(input, other, *, out=None) 
 Each element of the tensor input is multiplied by the corresponding element of the Tensor other. The resulting tensor is returned. The shapes of input and other must be broadcastable.  outi=inputi×otheri\text{out}_i = \text{input}_i \times \text{other}_i  
 Parameters 
 
input (Tensor) – the first multiplicand tensor 
other (Tensor) – the second multiplicand tensor   Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> a = torch.randn(4, 1)
>>> a
tensor([[ 1.1207],
        [-0.3137],
        [ 0.0700],
        [ 0.8378]])
>>> b = torch.randn(1, 4)
>>> b
tensor([[ 0.5146,  0.1216, -0.5244,  2.2382]])
>>> torch.mul(a, b)
tensor([[ 0.5767,  0.1363, -0.5877,  2.5083],
        [-0.1614, -0.0382,  0.1645, -0.7021],
        [ 0.0360,  0.0085, -0.0367,  0.1567],
        [ 0.4312,  0.1019, -0.4394,  1.8753]])
torch.multinomial(input, num_samples, replacement=False, *, generator=None, out=None) → LongTensor  
Returns a tensor where each row contains num_samples indices sampled from the multinomial probability distribution located in the corresponding row of tensor input.  Note The rows of input do not need to sum to one (in which case we use the values as weights), but must be non-negative, finite and have a non-zero sum.  Indices are ordered from left to right according to when each was sampled (first samples are placed in first column). If input is a vector, out is a vector of size num_samples. If input is a matrix with m rows, out is an matrix of shape (m×num_samples)(m \times \text{num\_samples}) . If replacement is True, samples are drawn with replacement. If not, they are drawn without replacement, which means that when a sample index is drawn for a row, it cannot be drawn again for that row.  Note When drawn without replacement, num_samples must be lower than number of non-zero elements in input (or the min number of non-zero elements in each row of input if it is a matrix).   Parameters 
 
input (Tensor) – the input tensor containing probabilities 
num_samples (int) – number of samples to draw 
replacement (bool, optional) – whether to draw with replacement or not   Keyword Arguments 
 
generator (torch.Generator, optional) – a pseudorandom number generator for sampling 
out (Tensor, optional) – the output tensor.    Example: >>> weights = torch.tensor([0, 10, 3, 0], dtype=torch.float) # create a tensor of weights
>>> torch.multinomial(weights, 2)
tensor([1, 2])
>>> torch.multinomial(weights, 4) # ERROR!
RuntimeError: invalid argument 2: invalid multinomial distribution (with replacement=False,
not enough non-negative category to sample) at ../aten/src/TH/generic/THTensorRandom.cpp:320
>>> torch.multinomial(weights, 4, replacement=True)
tensor([ 2,  1,  1,  1])
torch.multiply(input, other, *, out=None)  
Alias for torch.mul().
torch.multiprocessing.get_all_sharing_strategies() [source]
 
Returns a set of sharing strategies supported on a current system.
torch.multiprocessing.get_sharing_strategy() [source]
 
Returns the current strategy for sharing CPU tensors.
torch.multiprocessing.set_sharing_strategy(new_strategy) [source]
 
Sets the strategy for sharing CPU tensors.  Parameters 
new_strategy (str) – Name of the selected strategy. Should be one of the values returned by get_all_sharing_strategies().
torch.multiprocessing.spawn(fn, args=(), nprocs=1, join=True, daemon=False, start_method='spawn') [source]
 
Spawns nprocs processes that run fn with args. If one of the processes exits with a non-zero exit status, the remaining processes are killed and an exception is raised with the cause of termination. In the case an exception was caught in the child process, it is forwarded and its traceback is included in the exception raised in the parent process.  Parameters 
 
fn (function) – 
Function is called as the entrypoint of the spawned process. This function must be defined at the top level of a module so it can be pickled and spawned. This is a requirement imposed by multiprocessing. The function is called as fn(i, *args), where i is the process index and args is the passed through tuple of arguments.  
args (tuple) – Arguments passed to fn. 
nprocs (int) – Number of processes to spawn. 
join (bool) – Perform a blocking join on all processes. 
daemon (bool) – The spawned processes’ daemon flag. If set to True, daemonic processes will be created. 
start_method (string) – (deprecated) this method will always use spawn as the start method. To use a different start method use start_processes().   Returns 
None if join is True, ProcessContext if join is False
class torch.multiprocessing.SpawnContext [source]
 
Returned by spawn() when called with join=False.  
join(timeout=None)  
Tries to join one or more processes in this spawn context. If one of them exited with a non-zero exit status, this function kills the remaining processes and raises an exception with the cause of the first process exiting. Returns True if all processes have been joined successfully, False if there are more processes that need to be joined.  Parameters 
timeout (float) – Wait this long before giving up on waiting.
join(timeout=None)  
Tries to join one or more processes in this spawn context. If one of them exited with a non-zero exit status, this function kills the remaining processes and raises an exception with the cause of the first process exiting. Returns True if all processes have been joined successfully, False if there are more processes that need to be joined.  Parameters 
timeout (float) – Wait this long before giving up on waiting.
torch.mv(input, vec, *, out=None) → Tensor  
Performs a matrix-vector product of the matrix input and the vector vec. If input is a (n×m)(n \times m)  tensor, vec is a 1-D tensor of size mm , out will be 1-D of size nn .  Note This function does not broadcast.   Parameters 
 
input (Tensor) – matrix to be multiplied 
vec (Tensor) – vector to be multiplied   Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> mat = torch.randn(2, 3)
>>> vec = torch.randn(3)
>>> torch.mv(mat, vec)
tensor([ 1.0404, -0.6361])
torch.mvlgamma(input, p) → Tensor  
Computes the multivariate log-gamma function) with dimension pp  element-wise, given by  log⁡(Γp(a))=C+∑i=1plog⁡(Γ(a−i−12))\log(\Gamma_{p}(a)) = C + \displaystyle \sum_{i=1}^{p} \log\left(\Gamma\left(a - \frac{i - 1}{2}\right)\right)  
where C=log⁡(π)×p(p−1)4C = \log(\pi) \times \frac{p (p - 1)}{4}  and Γ(⋅)\Gamma(\cdot)  is the Gamma function. All elements must be greater than p−12\frac{p - 1}{2} , otherwise an error would be thrown.  Parameters 
 
input (Tensor) – the tensor to compute the multivariate log-gamma function 
p (int) – the number of dimensions    Example: >>> a = torch.empty(2, 3).uniform_(1, 2)
>>> a
tensor([[1.6835, 1.8474, 1.1929],
        [1.0475, 1.7162, 1.4180]])
>>> torch.mvlgamma(a, 2)
tensor([[0.3928, 0.4007, 0.7586],
        [1.0311, 0.3901, 0.5049]])
torch.nanmedian(input) → Tensor  
Returns the median of the values in input, ignoring NaN values. This function is identical to torch.median() when there are no NaN values in input. When input has one or more NaN values, torch.median() will always return NaN, while this function will return the median of the non-NaN elements in input. If all the elements in input are NaN it will also return NaN.  Parameters 
input (Tensor) – the input tensor.   Example: >>> a = torch.tensor([1, float('nan'), 3, 2])
>>> a.median()
tensor(nan)
>>> a.nanmedian()
tensor(2.)
  
torch.nanmedian(input, dim=-1, keepdim=False, *, out=None) -> (Tensor, LongTensor) 
 Returns a namedtuple (values, indices) where values contains the median of each row of input in the dimension dim, ignoring NaN values, and indices contains the index of the median values found in the dimension dim. This function is identical to torch.median() when there are no NaN values in a reduced row. When a reduced row has one or more NaN values, torch.median() will always reduce it to NaN, while this function will reduce it to the median of the non-NaN elements. If all the elements in a reduced row are NaN then it will be reduced to NaN, too.  Parameters 
 
input (Tensor) – the input tensor. 
dim (int) – the dimension to reduce. 
keepdim (bool) – whether the output tensor has dim retained or not.   Keyword Arguments 
out ((Tensor, Tensor), optional) – The first tensor will be populated with the median values and the second tensor, which must have dtype long, with their indices in the dimension dim of input.   Example: >>> a = torch.tensor([[2, 3, 1], [float('nan'), 1, float('nan')]])
>>> a
tensor([[2., 3., 1.],
        [nan, 1., nan]])
>>> a.median(0)
torch.return_types.median(values=tensor([nan, 1., nan]), indices=tensor([1, 1, 1]))
>>> a.nanmedian(0)
torch.return_types.nanmedian(values=tensor([2., 1., 1.]), indices=tensor([0, 1, 0]))
torch.nanquantile(input, q, dim=None, keepdim=False, *, out=None) → Tensor  
This is a variant of torch.quantile() that “ignores” NaN values, computing the quantiles q as if NaN values in input did not exist. If all values in a reduced row are NaN then the quantiles for that reduction will be NaN. See the documentation for torch.quantile().  Parameters 
 
input (Tensor) – the input tensor. 
q (float or Tensor) – a scalar or 1D tensor of quantile values in the range [0, 1] 
dim (int) – the dimension to reduce. 
keepdim (bool) – whether the output tensor has dim retained or not.   Keyword Arguments 
out (Tensor, optional) – the output tensor.   Example: >>> t = torch.tensor([float('nan'), 1, 2])
>>> t.quantile(0.5)
tensor(nan)
>>> t.nanquantile(0.5)
tensor(1.5000)

>>> t = torch.tensor([[float('nan'), float('nan')], [1, 2]])
>>> t
tensor([[nan, nan],
        [1., 2.]])
>>> t.nanquantile(0.5, dim=0)
tensor([1., 2.])
>>> t.nanquantile(0.5, dim=1)
tensor([   nan, 1.5000])
torch.nansum(input, *, dtype=None) → Tensor  
Returns the sum of all elements, treating Not a Numbers (NaNs) as zero.  Parameters 
input (Tensor) – the input tensor.  Keyword Arguments 
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.   Example: >>> a = torch.tensor([1., 2., float('nan'), 4.])
>>> torch.nansum(a)
tensor(7.)
  
torch.nansum(input, dim, keepdim=False, *, dtype=None) → Tensor 
 Returns the sum of each row of the input tensor in the given dimension dim, treating Not a Numbers (NaNs) as zero. 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).  Parameters 
 
input (Tensor) – the input tensor. 
dim (int or tuple of python:ints) – the dimension or dimensions to reduce. 
keepdim (bool) – whether the output tensor has dim retained or not.   Keyword Arguments 
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.   Example: >>> torch.nansum(torch.tensor([1., float("nan")]))
1.0
>>> a = torch.tensor([[1, 2], [3., float("nan")]])
>>> torch.nansum(a)
tensor(6.)
>>> torch.nansum(a, dim=0)
tensor([4., 2.])
>>> torch.nansum(a, dim=1)
tensor([3., 3.])