neulab/docprompting-conala huggingface dataset:
torch.nn.functional.affine_grid(theta, size, align_corners=None) [source]
 
Generates a 2D or 3D flow field (sampling grid), given a batch of affine matrices theta.  Note This function is often used in conjunction with grid_sample() to build Spatial Transformer Networks .   Parameters 
 
theta (Tensor) – input batch of affine matrices with shape (N×2×3N \times 2 \times 3 ) for 2D or (N×3×4N \times 3 \times 4 ) for 3D 
size (torch.Size) – the target output image size. (N×C×H×WN \times C \times H \times W  for 2D or N×C×D×H×WN \times C \times D \times H \times W  for 3D) Example: torch.Size((32, 3, 24, 24)) 
align_corners (bool, optional) – if True, consider -1 and 1 to refer to the centers of the corner pixels rather than the image corners. Refer to grid_sample() for a more complete description. A grid generated by affine_grid() should be passed to grid_sample() with the same setting for this option. Default: False
   Returns 
output Tensor of size (N×H×W×2N \times H \times W \times 2 )  Return type 
output (Tensor)    Warning When align_corners = True, the grid positions depend on the pixel size relative to the input image size, and so the locations sampled by grid_sample() will differ for the same input given at different resolutions (that is, after being upsampled or downsampled). The default behavior up to version 1.2.0 was align_corners = True. Since then, the default behavior has been changed to align_corners = False, in order to bring it in line with the default for interpolate().   Warning When align_corners = True, 2D affine transforms on 1D data and 3D affine transforms on 2D data (that is, when one of the spatial dimensions has unit size) are ill-defined, and not an intended use case. This is not a problem when align_corners = False. Up to version 1.2.0, all grid points along a unit dimension were considered arbitrarily to be at -1. From version 1.3.0, under align_corners = True all grid points along a unit dimension are considered to be at `0 (the center of the input image).
torch.nn.functional.alpha_dropout(input, p=0.5, training=False, inplace=False) [source]
 
Applies alpha dropout to the input. See AlphaDropout for details.
torch.nn.functional.avg_pool1d(input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True) → Tensor  
Applies a 1D average pooling over an input signal composed of several input planes. See AvgPool1d for details and output shape.  Parameters 
 
input – input tensor of shape (minibatch,in_channels,iW)(\text{minibatch} , \text{in\_channels} , iW) 
 
kernel_size – the size of the window. Can be a single number or a tuple (kW,)
 
stride – the stride of the window. Can be a single number or a tuple (sW,). Default: kernel_size
 
padding – implicit zero paddings on both sides of the input. Can be a single number or a tuple (padW,). Default: 0 
ceil_mode – when True, will use ceil instead of floor to compute the output shape. Default: False
 
count_include_pad – when True, will include the zero-padding in the averaging calculation. Default: True
    Examples: >>> # pool of square window of size=3, stride=2
>>> input = torch.tensor([[[1, 2, 3, 4, 5, 6, 7]]], dtype=torch.float32)
>>> F.avg_pool1d(input, kernel_size=3, stride=2)
tensor([[[ 2.,  4.,  6.]]])
torch.nn.functional.avg_pool2d(input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True, divisor_override=None) → Tensor  
Applies 2D average-pooling operation in kH×kWkH \times kW  regions by step size sH×sWsH \times sW  steps. The number of output features is equal to the number of input planes. See AvgPool2d for details and output shape.  Parameters 
 
input – input tensor (minibatch,in_channels,iH,iW)(\text{minibatch} , \text{in\_channels} , iH , iW) 
 
kernel_size – size of the pooling region. Can be a single number or a tuple (kH, kW)
 
stride – stride of the pooling operation. Can be a single number or a tuple (sH, sW). Default: kernel_size
 
padding – implicit zero paddings on both sides of the input. Can be a single number or a tuple (padH, padW). Default: 0 
ceil_mode – when True, will use ceil instead of floor in the formula to compute the output shape. Default: False
 
count_include_pad – when True, will include the zero-padding in the averaging calculation. Default: True
 
divisor_override – if specified, it will be used as divisor, otherwise size of the pooling region will be used. Default: None
torch.nn.functional.avg_pool3d(input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True, divisor_override=None) → Tensor  
Applies 3D average-pooling operation in kT×kH×kWkT \times kH \times kW  regions by step size sT×sH×sWsT \times sH \times sW  steps. The number of output features is equal to ⌊input planessT⌋\lfloor\frac{\text{input planes}}{sT}\rfloor . See AvgPool3d for details and output shape.  Parameters 
 
input – input tensor (minibatch,in_channels,iT×iH,iW)(\text{minibatch} , \text{in\_channels} , iT \times iH , iW) 
 
kernel_size – size of the pooling region. Can be a single number or a tuple (kT, kH, kW)
 
stride – stride of the pooling operation. Can be a single number or a tuple (sT, sH, sW). Default: kernel_size
 
padding – implicit zero paddings on both sides of the input. Can be a single number or a tuple (padT, padH, padW), Default: 0 
ceil_mode – when True, will use ceil instead of floor in the formula to compute the output shape 
count_include_pad – when True, will include the zero-padding in the averaging calculation 
divisor_override – if specified, it will be used as divisor, otherwise size of the pooling region will be used. Default: None
torch.nn.functional.batch_norm(input, running_mean, running_var, weight=None, bias=None, training=False, momentum=0.1, eps=1e-05) [source]
 
Applies Batch Normalization for each channel across a batch of data. See BatchNorm1d, BatchNorm2d, BatchNorm3d for details.
torch.nn.functional.bilinear(input1, input2, weight, bias=None) [source]
 
Applies a bilinear transformation to the incoming data: y=x1TAx2+by = x_1^T A x_2 + b  Shape:  input1: (N,∗,Hin1)(N, *, H_{in1})  where Hin1=in1_featuresH_{in1}=\text{in1\_features}  and ∗*  means any number of additional dimensions. All but the last dimension of the inputs should be the same. input2: (N,∗,Hin2)(N, *, H_{in2})  where Hin2=in2_featuresH_{in2}=\text{in2\_features} 
 weight: (out_features,in1_features,in2_features)(\text{out\_features}, \text{in1\_features}, \text{in2\_features}) 
 bias: (out_features)(\text{out\_features}) 
 output: (N,∗,Hout)(N, *, H_{out})  where Hout=out_featuresH_{out}=\text{out\_features}  and all but the last dimension are the same shape as the input.
torch.nn.functional.binary_cross_entropy(input, target, weight=None, size_average=None, reduce=None, reduction='mean') [source]
 
Function that measures the Binary Cross Entropy between the target and the output. See BCELoss for details.  Parameters 
 
input – Tensor of arbitrary shape 
target – Tensor of the same shape as input 
weight (Tensor, optional) – a manual rescaling weight if provided it’s repeated to match input tensor shape 
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' | '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'
    Examples: >>> input = torch.randn((3, 2), requires_grad=True)
>>> target = torch.rand((3, 2), requires_grad=False)
>>> loss = F.binary_cross_entropy(F.sigmoid(input), target)
>>> loss.backward()
torch.nn.functional.binary_cross_entropy_with_logits(input, target, weight=None, size_average=None, reduce=None, reduction='mean', pos_weight=None) [source]
 
Function that measures Binary Cross Entropy between target and output logits. See BCEWithLogitsLoss for details.  Parameters 
 
input – Tensor of arbitrary shape 
target – Tensor of the same shape as input 
weight (Tensor, optional) – a manual rescaling weight if provided it’s repeated to match input tensor shape 
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' | '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'
 
pos_weight (Tensor, optional) – a weight of positive examples. Must be a vector with length equal to the number of classes.    Examples: >>> input = torch.randn(3, requires_grad=True)
>>> target = torch.empty(3).random_(2)
>>> loss = F.binary_cross_entropy_with_logits(input, target)
>>> loss.backward()
torch.nn.functional.celu(input, alpha=1., inplace=False) → Tensor [source]
 
Applies element-wise, CELU(x)=max⁡(0,x)+min⁡(0,α∗(exp⁡(x/α)−1))\text{CELU}(x) = \max(0,x) + \min(0, \alpha * (\exp(x/\alpha) - 1)) . See CELU for more details.
torch.nn.functional.conv1d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1) → Tensor  
Applies a 1D convolution over an input signal composed of several input planes. This operator supports TensorFloat32. See Conv1d for details and output shape.  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.   Parameters 
 
input – input tensor of shape (minibatch,in_channels,iW)(\text{minibatch} , \text{in\_channels} , iW) 
 
weight – filters of shape (out_channels,in_channelsgroups,kW)(\text{out\_channels} , \frac{\text{in\_channels}}{\text{groups}} , kW) 
 
bias – optional bias of shape (out_channels)(\text{out\_channels}) . Default: None
 
stride – the stride of the convolving kernel. Can be a single number or a one-element tuple (sW,). Default: 1 
padding – implicit paddings on both sides of the input. Can be a single number or a one-element tuple (padW,). Default: 0 
dilation – the spacing between kernel elements. Can be a single number or a one-element tuple (dW,). Default: 1 
groups – split input into groups, in_channels\text{in\_channels}  should be divisible by the number of groups. Default: 1    Examples: >>> filters = torch.randn(33, 16, 3)
>>> inputs = torch.randn(20, 16, 50)
>>> F.conv1d(inputs, filters)
torch.nn.functional.conv2d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1) → Tensor  
Applies a 2D convolution over an input image composed of several input planes. This operator supports TensorFloat32. See Conv2d for details and output shape.  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.   Parameters 
 
input – input tensor of shape (minibatch,in_channels,iH,iW)(\text{minibatch} , \text{in\_channels} , iH , iW) 
 
weight – filters of shape (out_channels,in_channelsgroups,kH,kW)(\text{out\_channels} , \frac{\text{in\_channels}}{\text{groups}} , kH , kW) 
 
bias – optional bias tensor of shape (out_channels)(\text{out\_channels}) . Default: None
 
stride – the stride of the convolving kernel. Can be a single number or a tuple (sH, sW). Default: 1 
padding – implicit paddings on both sides of the input. Can be a single number or a tuple (padH, padW). Default: 0 
dilation – the spacing between kernel elements. Can be a single number or a tuple (dH, dW). Default: 1 
groups – split input into groups, in_channels\text{in\_channels}  should be divisible by the number of groups. Default: 1    Examples: >>> # With square kernels and equal stride
>>> filters = torch.randn(8,4,3,3)
>>> inputs = torch.randn(1,4,5,5)
>>> F.conv2d(inputs, filters, padding=1)
torch.nn.functional.conv3d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1) → Tensor  
Applies a 3D convolution over an input image composed of several input planes. This operator supports TensorFloat32. See Conv3d for details and output shape.  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.   Parameters 
 
input – input tensor of shape (minibatch,in_channels,iT,iH,iW)(\text{minibatch} , \text{in\_channels} , iT , iH , iW) 
 
weight – filters of shape (out_channels,in_channelsgroups,kT,kH,kW)(\text{out\_channels} , \frac{\text{in\_channels}}{\text{groups}} , kT , kH , kW) 
 
bias – optional bias tensor of shape (out_channels)(\text{out\_channels}) . Default: None 
stride – the stride of the convolving kernel. Can be a single number or a tuple (sT, sH, sW). Default: 1 
padding – implicit paddings on both sides of the input. Can be a single number or a tuple (padT, padH, padW). Default: 0 
dilation – the spacing between kernel elements. Can be a single number or a tuple (dT, dH, dW). Default: 1 
groups – split input into groups, in_channels\text{in\_channels}  should be divisible by the number of groups. Default: 1    Examples: >>> filters = torch.randn(33, 16, 3, 3, 3)
>>> inputs = torch.randn(20, 16, 50, 10, 20)
>>> F.conv3d(inputs, filters)
torch.nn.functional.conv_transpose1d(input, weight, bias=None, stride=1, padding=0, output_padding=0, groups=1, dilation=1) → Tensor  
Applies a 1D transposed convolution operator over an input signal composed of several input planes, sometimes also called “deconvolution”. This operator supports TensorFloat32. See ConvTranspose1d for details and output shape.  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.   Parameters 
 
input – input tensor of shape (minibatch,in_channels,iW)(\text{minibatch} , \text{in\_channels} , iW) 
 
weight – filters of shape (in_channels,out_channelsgroups,kW)(\text{in\_channels} , \frac{\text{out\_channels}}{\text{groups}} , kW) 
 
bias – optional bias of shape (out_channels)(\text{out\_channels}) . Default: None 
stride – the stride of the convolving kernel. Can be a single number or a tuple (sW,). Default: 1 
padding – dilation * (kernel_size - 1) - padding zero-padding will be added to both sides of each dimension in the input. Can be a single number or a tuple (padW,). Default: 0 
output_padding – additional size added to one side of each dimension in the output shape. Can be a single number or a tuple (out_padW). Default: 0 
groups – split input into groups, in_channels\text{in\_channels}  should be divisible by the number of groups. Default: 1 
dilation – the spacing between kernel elements. Can be a single number or a tuple (dW,). Default: 1    Examples: >>> inputs = torch.randn(20, 16, 50)
>>> weights = torch.randn(16, 33, 5)
>>> F.conv_transpose1d(inputs, weights)
torch.nn.functional.conv_transpose2d(input, weight, bias=None, stride=1, padding=0, output_padding=0, groups=1, dilation=1) → Tensor  
Applies a 2D transposed convolution operator over an input image composed of several input planes, sometimes also called “deconvolution”. This operator supports TensorFloat32. See ConvTranspose2d for details and output shape.  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.   Parameters 
 
input – input tensor of shape (minibatch,in_channels,iH,iW)(\text{minibatch} , \text{in\_channels} , iH , iW) 
 
weight – filters of shape (in_channels,out_channelsgroups,kH,kW)(\text{in\_channels} , \frac{\text{out\_channels}}{\text{groups}} , kH , kW) 
 
bias – optional bias of shape (out_channels)(\text{out\_channels}) . Default: None 
stride – the stride of the convolving kernel. Can be a single number or a tuple (sH, sW). Default: 1 
padding – dilation * (kernel_size - 1) - padding zero-padding will be added to both sides of each dimension in the input. Can be a single number or a tuple (padH, padW). Default: 0 
output_padding – additional size added to one side of each dimension in the output shape. Can be a single number or a tuple (out_padH, out_padW). Default: 0 
groups – split input into groups, in_channels\text{in\_channels}  should be divisible by the number of groups. Default: 1 
dilation – the spacing between kernel elements. Can be a single number or a tuple (dH, dW). Default: 1    Examples: >>> # With square kernels and equal stride
>>> inputs = torch.randn(1, 4, 5, 5)
>>> weights = torch.randn(4, 8, 3, 3)
>>> F.conv_transpose2d(inputs, weights, padding=1)
torch.nn.functional.conv_transpose3d(input, weight, bias=None, stride=1, padding=0, output_padding=0, groups=1, dilation=1) → Tensor  
Applies a 3D transposed convolution operator over an input image composed of several input planes, sometimes also called “deconvolution” This operator supports TensorFloat32. See ConvTranspose3d for details and output shape.  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.   Parameters 
 
input – input tensor of shape (minibatch,in_channels,iT,iH,iW)(\text{minibatch} , \text{in\_channels} , iT , iH , iW) 
 
weight – filters of shape (in_channels,out_channelsgroups,kT,kH,kW)(\text{in\_channels} , \frac{\text{out\_channels}}{\text{groups}} , kT , kH , kW) 
 
bias – optional bias of shape (out_channels)(\text{out\_channels}) . Default: None 
stride – the stride of the convolving kernel. Can be a single number or a tuple (sT, sH, sW). Default: 1 
padding – dilation * (kernel_size - 1) - padding zero-padding will be added to both sides of each dimension in the input. Can be a single number or a tuple (padT, padH, padW). Default: 0 
output_padding – additional size added to one side of each dimension in the output shape. Can be a single number or a tuple (out_padT, out_padH, out_padW). Default: 0 
groups – split input into groups, in_channels\text{in\_channels}  should be divisible by the number of groups. Default: 1 
dilation – the spacing between kernel elements. Can be a single number or a tuple (dT, dH, dW). Default: 1    Examples: >>> inputs = torch.randn(20, 16, 50, 10, 20)
>>> weights = torch.randn(16, 33, 3, 3, 3)
>>> F.conv_transpose3d(inputs, weights)
torch.nn.functional.cosine_embedding_loss(input1, input2, target, margin=0, size_average=None, reduce=None, reduction='mean') → Tensor [source]
 
See CosineEmbeddingLoss for details.
torch.nn.functional.cosine_similarity(x1, x2, dim=1, eps=1e-8) → Tensor  
Returns cosine similarity between x1 and x2, computed along dim.  similarity=x1⋅x2max⁡(∥x1∥2⋅∥x2∥2,ϵ)\text{similarity} = \dfrac{x_1 \cdot x_2}{\max(\Vert x_1 \Vert _2 \cdot \Vert x_2 \Vert _2, \epsilon)}  
 Parameters 
 
x1 (Tensor) – First input. 
x2 (Tensor) – Second input (of size matching x1). 
dim (int, optional) – Dimension of vectors. Default: 1 
eps (float, optional) – Small value to avoid division by zero. Default: 1e-8     Shape:

 Input: (∗1,D,∗2)(\ast_1, D, \ast_2)  where D is at position dim. Output: (∗1,∗2)(\ast_1, \ast_2)  where 1 is at position dim.    Example: >>> input1 = torch.randn(100, 128)
>>> input2 = torch.randn(100, 128)
>>> output = F.cosine_similarity(input1, input2)
>>> print(output)
torch.nn.functional.cross_entropy(input, target, weight=None, size_average=None, ignore_index=-100, reduce=None, reduction='mean') [source]
 
This criterion combines log_softmax and nll_loss in a single function. See CrossEntropyLoss for details.  Parameters 
 
input (Tensor) – (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 (Tensor) – (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'
    Examples: >>> input = torch.randn(3, 5, requires_grad=True)
>>> target = torch.randint(5, (3,), dtype=torch.int64)
>>> loss = F.cross_entropy(input, target)
>>> loss.backward()