neulab/docprompting-conala huggingface dataset:
torch.nn.functional.ctc_loss(log_probs, targets, input_lengths, target_lengths, blank=0, reduction='mean', zero_infinity=False) [source]
 
The Connectionist Temporal Classification loss. See CTCLoss for details.  Note In some circumstances when given tensors on a CUDA device and using CuDNN, this operator may select a nondeterministic algorithm to increase performance. If this is undesirable, you can try to make the operation deterministic (potentially at a performance cost) by setting torch.backends.cudnn.deterministic = True. See Reproducibility for more information.   Note This operation may produce nondeterministic gradients when given tensors on a CUDA device. See Reproducibility for more information.   Parameters 
 
log_probs – (T,N,C)(T, N, C)  where C = number of characters in alphabet including blank, T = input length, and N = batch size. The logarithmized probabilities of the outputs (e.g. obtained with torch.nn.functional.log_softmax()). 
targets – (N,S)(N, S)  or (sum(target_lengths)). Targets cannot be blank. In the second form, the targets are assumed to be concatenated. 
input_lengths – (N)(N) . Lengths of the inputs (must each be ≤T\leq T ) 
target_lengths – (N)(N) . Lengths of the targets 
blank (int, optional) – Blank label. Default 00 . 
reduction (string, optional) – Specifies the reduction to apply to the output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': the output losses will be divided by the target lengths and then the mean over the batch is taken, 'sum': the output will be summed. Default: 'mean'
 
zero_infinity (bool, optional) – Whether to zero infinite losses and the associated gradients. Default: False Infinite losses mainly occur when the inputs are too short to be aligned to the targets.    Example: >>> log_probs = torch.randn(50, 16, 20).log_softmax(2).detach().requires_grad_()
>>> targets = torch.randint(1, 20, (16, 30), dtype=torch.long)
>>> input_lengths = torch.full((16,), 50, dtype=torch.long)
>>> target_lengths = torch.randint(10,30,(16,), dtype=torch.long)
>>> loss = F.ctc_loss(log_probs, targets, input_lengths, target_lengths)
>>> loss.backward()
torch.nn.functional.dropout(input, p=0.5, training=True, inplace=False) [source]
 
During training, randomly zeroes some of the elements of the input tensor with probability p using samples from a Bernoulli distribution. See Dropout for details.  Parameters 
 
p – probability of an element to be zeroed. Default: 0.5 
training – apply dropout if is True. Default: True
 
inplace – If set to True, will do this operation in-place. Default: False
torch.nn.functional.dropout2d(input, p=0.5, training=True, inplace=False) [source]
 
Randomly zero out entire channels (a channel is a 2D feature map, e.g., the jj -th channel of the ii -th sample in the batched input is a 2D tensor input[i,j]\text{input}[i, j] ) of the input tensor). Each channel will be zeroed out independently on every forward call with probability p using samples from a Bernoulli distribution. See Dropout2d for details.  Parameters 
 
p – probability of a channel to be zeroed. Default: 0.5 
training – apply dropout if is True. Default: True
 
inplace – If set to True, will do this operation in-place. Default: False
torch.nn.functional.dropout3d(input, p=0.5, training=True, inplace=False) [source]
 
Randomly zero out entire channels (a channel is a 3D feature map, e.g., the jj -th channel of the ii -th sample in the batched input is a 3D tensor input[i,j]\text{input}[i, j] ) of the input tensor). Each channel will be zeroed out independently on every forward call with probability p using samples from a Bernoulli distribution. See Dropout3d for details.  Parameters 
 
p – probability of a channel to be zeroed. Default: 0.5 
training – apply dropout if is True. Default: True
 
inplace – If set to True, will do this operation in-place. Default: False
torch.nn.functional.elu(input, alpha=1.0, inplace=False) [source]
 
Applies element-wise, ELU(x)=max⁡(0,x)+min⁡(0,α∗(exp⁡(x)−1))\text{ELU}(x) = \max(0,x) + \min(0, \alpha * (\exp(x) - 1)) . See ELU for more details.
torch.nn.functional.elu_(input, alpha=1.) → Tensor  
In-place version of elu().
torch.nn.functional.embedding(input, weight, padding_idx=None, max_norm=None, norm_type=2.0, scale_grad_by_freq=False, sparse=False) [source]
 
A simple lookup table that looks up embeddings in a fixed dictionary and size. This module is often used to retrieve word embeddings using indices. The input to the module is a list of indices, and the embedding matrix, and the output is the corresponding word embeddings. See torch.nn.Embedding for more details.  Parameters 
 
input (LongTensor) – Tensor containing indices into the embedding matrix 
weight (Tensor) – The embedding matrix with number of rows equal to the maximum possible index + 1, and number of columns equal to the embedding size 
padding_idx (int, optional) – If given, pads the output with the embedding vector at padding_idx (initialized to zeros) whenever it encounters the index. 
max_norm (float, optional) – If given, each embedding vector with norm larger than max_norm is renormalized to have norm max_norm. Note: this will modify weight in-place. 
norm_type (float, optional) – The p of the p-norm to compute for the max_norm option. Default 2. 
scale_grad_by_freq (boolean, optional) – If given, this will scale gradients by the inverse of frequency of the words in the mini-batch. Default False. 
sparse (bool, optional) – If True, gradient w.r.t. weight will be a sparse tensor. See Notes under torch.nn.Embedding for more details regarding sparse gradients.     Shape:

 Input: LongTensor of arbitrary shape containing the indices to extract 
 
Weight: Embedding matrix of floating point type with shape (V, embedding_dim), 

where V = maximum index + 1 and embedding_dim = the embedding size    Output: (*, embedding_dim), where * is the input shape    Examples: >>> # a batch of 2 samples of 4 indices each
>>> input = torch.tensor([[1,2,4,5],[4,3,2,9]])
>>> # an embedding matrix containing 10 tensors of size 3
>>> embedding_matrix = torch.rand(10, 3)
>>> F.embedding(input, embedding_matrix)
tensor([[[ 0.8490,  0.9625,  0.6753],
         [ 0.9666,  0.7761,  0.6108],
         [ 0.6246,  0.9751,  0.3618],
         [ 0.4161,  0.2419,  0.7383]],

        [[ 0.6246,  0.9751,  0.3618],
         [ 0.0237,  0.7794,  0.0528],
         [ 0.9666,  0.7761,  0.6108],
         [ 0.3385,  0.8612,  0.1867]]])

>>> # example with padding_idx
>>> weights = torch.rand(10, 3)
>>> weights[0, :].zero_()
>>> embedding_matrix = weights
>>> input = torch.tensor([[0,2,0,5]])
>>> F.embedding(input, embedding_matrix, padding_idx=0)
tensor([[[ 0.0000,  0.0000,  0.0000],
         [ 0.5609,  0.5384,  0.8720],
         [ 0.0000,  0.0000,  0.0000],
         [ 0.6262,  0.2438,  0.7471]]])
torch.nn.functional.feature_alpha_dropout(input, p=0.5, training=False, inplace=False) [source]
 
Randomly masks out entire channels (a channel is a feature map, e.g. the jj -th channel of the ii -th sample in the batch input is a tensor input[i,j]\text{input}[i, j] ) of the input tensor). Instead of setting activations to zero, as in regular Dropout, the activations are set to the negative saturation value of the SELU activation function. Each element will be masked independently on every forward call with probability p using samples from a Bernoulli distribution. The elements to be masked are randomized on every forward call, and scaled and shifted to maintain zero mean and unit variance. See FeatureAlphaDropout for details.  Parameters 
 
p – dropout probability of a channel to be zeroed. Default: 0.5 
training – apply dropout if is True. Default: True
 
inplace – If set to True, will do this operation in-place. Default: False
torch.nn.functional.fold(input, output_size, kernel_size, dilation=1, padding=0, stride=1) [source]
 
Combines an array of sliding local blocks into a large containing tensor.  Warning Currently, only 3-D output tensors (unfolded batched image-like tensors) are supported.  See torch.nn.Fold for details
torch.nn.functional.gelu(input) → Tensor [source]
 
Applies element-wise the function GELU(x)=x∗Φ(x)\text{GELU}(x) = x * \Phi(x)  where Φ(x)\Phi(x)  is the Cumulative Distribution Function for Gaussian Distribution. See Gaussian Error Linear Units (GELUs).
torch.nn.functional.glu(input, dim=-1) → Tensor [source]
 
The gated linear unit. Computes:  GLU(a,b)=a⊗σ(b)\text{GLU}(a, b) = a \otimes \sigma(b)  
where input is split in half along dim to form a and b, σ\sigma  is the sigmoid function and ⊗\otimes  is the element-wise product between matrices. See Language Modeling with Gated Convolutional Networks.  Parameters 
 
input (Tensor) – input tensor 
dim (int) – dimension on which to split the input. Default: -1
torch.nn.functional.gumbel_softmax(logits, tau=1, hard=False, eps=1e-10, dim=-1) [source]
 
Samples from the Gumbel-Softmax distribution (Link 1 Link 2) and optionally discretizes.  Parameters 
 
logits – […, num_features] unnormalized log probabilities 
tau – non-negative scalar temperature 
hard – if True, the returned samples will be discretized as one-hot vectors, but will be differentiated as if it is the soft sample in autograd 
dim (int) – A dimension along which softmax will be computed. Default: -1.   Returns 
Sampled tensor of same shape as logits from the Gumbel-Softmax distribution. If hard=True, the returned samples will be one-hot, otherwise they will be probability distributions that sum to 1 across dim.    Note This function is here for legacy reasons, may be removed from nn.Functional in the future.   Note The main trick for hard is to do y_hard - y_soft.detach() + y_soft It achieves two things: - makes the output value exactly one-hot (since we add then subtract y_soft value) - makes the gradient equal to y_soft gradient (since we strip all other gradients)   Examples::

>>> logits = torch.randn(20, 32)
>>> # Sample soft categorical using reparametrization trick:
>>> F.gumbel_softmax(logits, tau=1, hard=False)
>>> # Sample hard categorical using "Straight-through" trick:
>>> F.gumbel_softmax(logits, tau=1, hard=True)
torch.nn.functional.hardshrink(input, lambd=0.5) → Tensor [source]
 
Applies the hard shrinkage function element-wise See Hardshrink for more details.
torch.nn.functional.hardsigmoid(input) → Tensor [source]
 
Applies the element-wise function  Hardsigmoid(x)={0if x≤−3,1if x≥+3,x/6+1/2otherwise\text{Hardsigmoid}(x) = \begin{cases} 0 & \text{if~} x \le -3, \\ 1 & \text{if~} x \ge +3, \\ x / 6 + 1 / 2 & \text{otherwise} \end{cases}  
 Parameters 
inplace – If set to True, will do this operation in-place. Default: False   See Hardsigmoid for more details.
torch.nn.functional.hardswish(input, inplace=False) [source]
 
Applies the hardswish function, element-wise, as described in the paper: Searching for MobileNetV3.  Hardswish(x)={0if x≤−3,xif x≥+3,x⋅(x+3)/6otherwise\text{Hardswish}(x) = \begin{cases} 0 & \text{if~} x \le -3, \\ x & \text{if~} x \ge +3, \\ x \cdot (x + 3) /6 & \text{otherwise} \end{cases}  
See Hardswish for more details.
torch.nn.functional.hardtanh(input, min_val=-1., max_val=1., inplace=False) → Tensor [source]
 
Applies the HardTanh function element-wise. See Hardtanh for more details.
torch.nn.functional.hardtanh_(input, min_val=-1., max_val=1.) → Tensor  
In-place version of hardtanh().
torch.nn.functional.hinge_embedding_loss(input, target, margin=1.0, size_average=None, reduce=None, reduction='mean') → Tensor [source]
 
See HingeEmbeddingLoss for details.
torch.nn.functional.instance_norm(input, running_mean=None, running_var=None, weight=None, bias=None, use_input_stats=True, momentum=0.1, eps=1e-05) [source]
 
Applies Instance Normalization for each channel in each data sample in a batch. See InstanceNorm1d, InstanceNorm2d, InstanceNorm3d for details.
torch.nn.functional.kl_div(input, target, size_average=None, reduce=None, reduction='mean', log_target=False) [source]
 
The Kullback-Leibler divergence Loss See KLDivLoss for details.  Parameters 
 
input – Tensor of arbitrary shape 
target – Tensor of the same shape as input 
size_average (bool, optional) – Deprecated (see reduction). By default, the losses are averaged over each loss element in the batch. Note that for some losses, there multiple elements per sample. If the field size_average is set to False, the losses are instead summed for each minibatch. Ignored when reduce is False. Default: True
 
reduce (bool, optional) – Deprecated (see reduction). By default, the losses are averaged or summed over observations for each minibatch depending on size_average. When reduce is False, returns a loss per batch element instead and ignores size_average. Default: True
 
reduction (string, optional) – Specifies the reduction to apply to the output: 'none' | 'batchmean' | 'sum' | 'mean'. 'none': no reduction will be applied 'batchmean': the sum of the output will be divided by the batchsize 'sum': the output will be summed 'mean': the output will be divided by the number of elements in the output Default: 'mean'
 
log_target (bool) – A flag indicating whether target is passed in the log space. It is recommended to pass certain distributions (like softmax) in the log space to avoid numerical issues caused by explicit log. Default: False
     Note size_average and reduce are in the process of being deprecated, and in the meantime, specifying either of those two args will override reduction.   Note :attr:reduction = 'mean' doesn’t return the true kl divergence value, please use :attr:reduction = 'batchmean' which aligns with KL math definition. In the next major release, 'mean' will be changed to be the same as ‘batchmean’.
torch.nn.functional.l1_loss(input, target, size_average=None, reduce=None, reduction='mean') → Tensor [source]
 
Function that takes the mean element-wise absolute value difference. See L1Loss for details.
torch.nn.functional.layer_norm(input, normalized_shape, weight=None, bias=None, eps=1e-05) [source]
 
Applies Layer Normalization for last certain number of dimensions. See LayerNorm for details.
torch.nn.functional.leaky_relu(input, negative_slope=0.01, inplace=False) → Tensor [source]
 
Applies element-wise, LeakyReLU(x)=max⁡(0,x)+negative_slope∗min⁡(0,x)\text{LeakyReLU}(x) = \max(0, x) + \text{negative\_slope} * \min(0, x)  See LeakyReLU for more details.
torch.nn.functional.leaky_relu_(input, negative_slope=0.01) → Tensor  
In-place version of leaky_relu().
torch.nn.functional.linear(input, weight, bias=None) [source]
 
Applies a linear transformation to the incoming data: y=xAT+by = xA^T + b . This operator supports TensorFloat32. Shape:  Input: (N,∗,in_features)(N, *, in\_features)  N is the batch size, * means any number of additional dimensions Weight: (out_features,in_features)(out\_features, in\_features) 
 Bias: (out_features)(out\_features) 
 Output: (N,∗,out_features)(N, *, out\_features)
torch.nn.functional.local_response_norm(input, size, alpha=0.0001, beta=0.75, k=1.0) [source]
 
Applies local response normalization over an input signal composed of several input planes, where channels occupy the second dimension. Applies normalization across channels. See LocalResponseNorm for details.
torch.nn.functional.logsigmoid(input) → Tensor  
Applies element-wise LogSigmoid(xi)=log⁡(11+exp⁡(−xi))\text{LogSigmoid}(x_i) = \log \left(\frac{1}{1 + \exp(-x_i)}\right)  See LogSigmoid for more details.
torch.nn.functional.log_softmax(input, dim=None, _stacklevel=3, dtype=None) [source]
 
Applies a softmax followed by a logarithm. While mathematically equivalent to log(softmax(x)), doing these two operations separately is slower, and numerically unstable. This function uses an alternative formulation to compute the output and gradient correctly. See LogSoftmax for more details.  Parameters 
 
input (Tensor) – input 
dim (int) – A dimension along which log_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.nn.functional.lp_pool1d(input, norm_type, kernel_size, stride=None, ceil_mode=False) [source]
 
Applies a 1D power-average pooling over an input signal composed of several input planes. If the sum of all inputs to the power of p is zero, the gradient is set to zero as well. See LPPool1d for details.
torch.nn.functional.lp_pool2d(input, norm_type, kernel_size, stride=None, ceil_mode=False) [source]
 
Applies a 2D power-average pooling over an input signal composed of several input planes. If the sum of all inputs to the power of p is zero, the gradient is set to zero as well. See LPPool2d for details.
torch.nn.functional.margin_ranking_loss(input1, input2, target, margin=0, size_average=None, reduce=None, reduction='mean') → Tensor [source]
 
See MarginRankingLoss for details.
torch.nn.functional.max_pool1d(*args, **kwargs)  
Applies a 1D max pooling over an input signal composed of several input planes. See MaxPool1d for details.
torch.nn.functional.max_pool2d(*args, **kwargs)  
Applies a 2D max pooling over an input signal composed of several input planes. See MaxPool2d for details.
torch.nn.functional.max_pool3d(*args, **kwargs)  
Applies a 3D max pooling over an input signal composed of several input planes. See MaxPool3d for details.
torch.nn.functional.max_unpool1d(input, indices, kernel_size, stride=None, padding=0, output_size=None) [source]
 
Computes a partial inverse of MaxPool1d. See MaxUnpool1d for details.
torch.nn.functional.max_unpool2d(input, indices, kernel_size, stride=None, padding=0, output_size=None) [source]
 
Computes a partial inverse of MaxPool2d. See MaxUnpool2d for details.
torch.nn.functional.max_unpool3d(input, indices, kernel_size, stride=None, padding=0, output_size=None) [source]
 
Computes a partial inverse of MaxPool3d. See MaxUnpool3d for details.
torch.nn.functional.mse_loss(input, target, size_average=None, reduce=None, reduction='mean') → Tensor [source]
 
Measures the element-wise mean squared error. See MSELoss for details.
torch.nn.functional.multilabel_margin_loss(input, target, size_average=None, reduce=None, reduction='mean') → Tensor [source]
 
See MultiLabelMarginLoss for details.
torch.nn.functional.multilabel_soft_margin_loss(input, target, weight=None, size_average=None) → Tensor [source]
 
See MultiLabelSoftMarginLoss for details.
torch.nn.functional.multi_margin_loss(input, target, p=1, margin=1.0, weight=None, size_average=None, reduce=None, reduction='mean') [source]
 
 multi_margin_loss(input, target, p=1, margin=1, weight=None, size_average=None,

reduce=None, reduction=’mean’) -> Tensor   See MultiMarginLoss for details.
torch.nn.functional.nll_loss(input, target, weight=None, size_average=None, ignore_index=-100, reduce=None, reduction='mean') [source]
 
The negative log likelihood loss. See NLLLoss for details.  Parameters 
 
input – (N,C)(N, C)  where C = number of classes or (N,C,H,W)(N, C, H, W)  in case of 2D Loss, or (N,C,d1,d2,...,dK)(N, C, d_1, d_2, ..., d_K)  where K≥1K \geq 1  in the case of K-dimensional loss. 
target – (N)(N)  where each value is 0≤targets[i]≤C−10 \leq \text{targets}[i] \leq C-1 , or (N,d1,d2,...,dK)(N, d_1, d_2, ..., d_K)  where K≥1K \geq 1  for K-dimensional loss. 
weight (Tensor, optional) – a manual rescaling weight given to each class. If given, has to be a Tensor of size C
 
size_average (bool, optional) – Deprecated (see reduction). By default, the losses are averaged over each loss element in the batch. Note that for some losses, there multiple elements per sample. If the field size_average is set to False, the losses are instead summed for each minibatch. Ignored when reduce is False. Default: True
 
ignore_index (int, optional) – Specifies a target value that is ignored and does not contribute to the input gradient. When size_average is True, the loss is averaged over non-ignored targets. Default: -100 
reduce (bool, optional) – Deprecated (see reduction). By default, the losses are averaged or summed over observations for each minibatch depending on size_average. When reduce is False, returns a loss per batch element instead and ignores size_average. Default: True
 
reduction (string, optional) – Specifies the reduction to apply to the output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': the sum of the output will be divided by the number of elements in the output, 'sum': the output will be summed. Note: size_average and reduce are in the process of being deprecated, and in the meantime, specifying either of those two args will override reduction. Default: 'mean'
    Example: >>> # input is of size N x C = 3 x 5
>>> input = torch.randn(3, 5, requires_grad=True)
>>> # each element in target has to have 0 <= value < C
>>> target = torch.tensor([1, 0, 4])
>>> output = F.nll_loss(F.log_softmax(input), target)
>>> output.backward()
torch.nn.functional.normalize(input, p=2, dim=1, eps=1e-12, out=None) [source]
 
Performs LpL_p  normalization of inputs over specified dimension. For a tensor input of sizes (n0,...,ndim,...,nk)(n_0, ..., n_{dim}, ..., n_k) , each ndimn_{dim}  -element vector vv  along dimension dim is transformed as  v=vmax⁡(∥v∥p,ϵ).v = \frac{v}{\max(\lVert v \rVert_p, \epsilon)}.  
With the default arguments it uses the Euclidean norm over vectors along dimension 11  for normalization.  Parameters 
 
input – input tensor of any shape 
p (float) – the exponent value in the norm formulation. Default: 2 
dim (int) – the dimension to reduce. Default: 1 
eps (float) – small value to avoid division by zero. Default: 1e-12 
out (Tensor, optional) – the output tensor. If out is used, this operation won’t be differentiable.
torch.nn.functional.one_hot(tensor, num_classes=-1) → LongTensor  
Takes LongTensor with index values of shape (*) and returns a tensor of shape (*, num_classes) that have zeros everywhere except where the index of last dimension matches the corresponding value of the input tensor, in which case it will be 1. See also One-hot on Wikipedia .  Parameters 
 
tensor (LongTensor) – class values of any shape. 
num_classes (int) – Total number of classes. If set to -1, the number of classes will be inferred as one greater than the largest class value in the input tensor.   Returns 
LongTensor that has one more dimension with 1 values at the index of last dimension indicated by the input, and 0 everywhere else.   Examples >>> F.one_hot(torch.arange(0, 5) % 3)
tensor([[1, 0, 0],
        [0, 1, 0],
        [0, 0, 1],
        [1, 0, 0],
        [0, 1, 0]])
>>> F.one_hot(torch.arange(0, 5) % 3, num_classes=5)
tensor([[1, 0, 0, 0, 0],
        [0, 1, 0, 0, 0],
        [0, 0, 1, 0, 0],
        [1, 0, 0, 0, 0],
        [0, 1, 0, 0, 0]])
>>> F.one_hot(torch.arange(0, 6).view(3,2) % 3)
tensor([[[1, 0, 0],
         [0, 1, 0]],
        [[0, 0, 1],
         [1, 0, 0]],
        [[0, 1, 0],
         [0, 0, 1]]])