neulab/docprompting-conala huggingface dataset:
class torch.nn.BatchNorm3d(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) [source]
 
Applies Batch Normalization over a 5D input (a mini-batch of 3D inputs with additional channel dimension) as described in the paper Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift .  y=x−E[x]Var[x]+ϵ∗γ+βy = \frac{x - \mathrm{E}[x]}{ \sqrt{\mathrm{Var}[x] + \epsilon}} * \gamma + \beta 
The mean and standard-deviation are calculated per-dimension over the mini-batches and γ\gamma  and β\beta  are learnable parameter vectors of size C (where C is the input size). By default, the elements of γ\gamma  are set to 1 and the elements of β\beta  are set to 0. The standard-deviation is calculated via the biased estimator, equivalent to torch.var(input, unbiased=False). Also by default, during training this layer keeps running estimates of its computed mean and variance, which are then used for normalization during evaluation. The running estimates are kept with a default momentum of 0.1. If track_running_stats is set to False, this layer then does not keep running estimates, and batch statistics are instead used during evaluation time as well.  Note This momentum argument is different from one used in optimizer classes and the conventional notion of momentum. Mathematically, the update rule for running statistics here is x^new=(1−momentum)×x^+momentum×xt\hat{x}_\text{new} = (1 - \text{momentum}) \times \hat{x} + \text{momentum} \times x_t , where x^\hat{x}  is the estimated statistic and xtx_t  is the new observed value.  Because the Batch Normalization is done over the C dimension, computing statistics on (N, D, H, W) slices, it’s common terminology to call this Volumetric Batch Normalization or Spatio-temporal Batch Normalization.  Parameters 
 
num_features – CC  from an expected input of size (N,C,D,H,W)(N, C, D, H, W) 
 
eps – a value added to the denominator for numerical stability. Default: 1e-5 
momentum – the value used for the running_mean and running_var computation. Can be set to None for cumulative moving average (i.e. simple average). Default: 0.1 
affine – a boolean value that when set to True, this module has learnable affine parameters. Default: True
 
track_running_stats – a boolean value that when set to True, this module tracks the running mean and variance, and when set to False, this module does not track such statistics, and initializes statistics buffers running_mean and running_var as None. When these buffers are None, this module always uses batch statistics. in both training and eval modes. Default: True
     Shape:

 Input: (N,C,D,H,W)(N, C, D, H, W) 
 Output: (N,C,D,H,W)(N, C, D, H, W)  (same shape as input)    Examples: >>> # With Learnable Parameters
>>> m = nn.BatchNorm3d(100)
>>> # Without Learnable Parameters
>>> m = nn.BatchNorm3d(100, affine=False)
>>> input = torch.randn(20, 100, 35, 45, 10)
>>> output = m(input)
class torch.nn.Bilinear(in1_features, in2_features, out_features, bias=True) [source]
 
Applies a bilinear transformation to the incoming data: y=x1TAx2+by = x_1^T A x_2 + b   Parameters 
 
in1_features – size of each first input sample 
in2_features – size of each second input sample 
out_features – size of each output sample 
bias – If set to False, the layer will not learn an additive bias. Default: True
     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} . 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.     Variables 
 
~Bilinear.weight – the learnable weights of the module of shape (out_features,in1_features,in2_features)(\text{out\_features}, \text{in1\_features}, \text{in2\_features}) . The values are initialized from U(−k,k)\mathcal{U}(-\sqrt{k}, \sqrt{k}) , where k=1in1_featuresk = \frac{1}{\text{in1\_features}} 
 
~Bilinear.bias – the learnable bias of the module of shape (out_features)(\text{out\_features}) . If bias is True, the values are initialized from U(−k,k)\mathcal{U}(-\sqrt{k}, \sqrt{k}) , where k=1in1_featuresk = \frac{1}{\text{in1\_features}} 
    Examples: >>> m = nn.Bilinear(20, 30, 40)
>>> input1 = torch.randn(128, 20)
>>> input2 = torch.randn(128, 30)
>>> output = m(input1, input2)
>>> print(output.size())
torch.Size([128, 40])
class torch.nn.CELU(alpha=1.0, inplace=False) [source]
 
Applies the element-wise function:  CELU(x)=max⁡(0,x)+min⁡(0,α∗(exp⁡(x/α)−1))\text{CELU}(x) = \max(0,x) + \min(0, \alpha * (\exp(x/\alpha) - 1))  
More details can be found in the paper Continuously Differentiable Exponential Linear Units .  Parameters 
 
alpha – the α\alpha  value for the CELU formulation. Default: 1.0 
inplace – can optionally do the operation in-place. Default: False
     Shape:

 Input: (N,∗)(N, *)  where * means, any number of additional dimensions Output: (N,∗)(N, *) , same shape as the input     Examples: >>> m = nn.CELU()
>>> input = torch.randn(2)
>>> output = m(input)
class torch.nn.ChannelShuffle(groups) [source]
 
Divide the channels in a tensor of shape (∗,C,H,W)(*, C , H, W)  into g groups and rearrange them as (∗,Cg,g,H,W)(*, C \frac g, g, H, W) , while keeping the original tensor shape.  Parameters 
groups (int) – number of groups to divide channels in.   Examples: >>> channel_shuffle = nn.ChannelShuffle(2)
>>> input = torch.randn(1, 4, 2, 2)
>>> print(input)
[[[[1, 2],
   [3, 4]],
  [[5, 6],
   [7, 8]],
  [[9, 10],
   [11, 12]],
  [[13, 14],
   [15, 16]],
 ]]
>>> output = channel_shuffle(input)
>>> print(output)
[[[[1, 2],
   [3, 4]],
  [[9, 10],
   [11, 12]],
  [[5, 6],
   [7, 8]],
  [[13, 14],
   [15, 16]],
 ]]
class torch.nn.ConstantPad1d(padding, value) [source]
 
Pads the input tensor boundaries with a constant value. For N-dimensional padding, use torch.nn.functional.pad().  Parameters 
padding (int, tuple) – the size of the padding. If is int, uses the same padding in both boundaries. If a 2-tuple, uses (padding_left\text{padding\_left} , padding_right\text{padding\_right} )    Shape:

 Input: (N,C,Win)(N, C, W_{in}) 
 
Output: (N,C,Wout)(N, C, W_{out})  where Wout=Win+padding_left+padding_rightW_{out} = W_{in} + \text{padding\_left} + \text{padding\_right}      Examples: >>> m = nn.ConstantPad1d(2, 3.5)
>>> input = torch.randn(1, 2, 4)
>>> input
tensor([[[-1.0491, -0.7152, -0.0749,  0.8530],
         [-1.3287,  1.8966,  0.1466, -0.2771]]])
>>> m(input)
tensor([[[ 3.5000,  3.5000, -1.0491, -0.7152, -0.0749,  0.8530,  3.5000,
           3.5000],
         [ 3.5000,  3.5000, -1.3287,  1.8966,  0.1466, -0.2771,  3.5000,
           3.5000]]])
>>> m = nn.ConstantPad1d(2, 3.5)
>>> input = torch.randn(1, 2, 3)
>>> input
tensor([[[ 1.6616,  1.4523, -1.1255],
         [-3.6372,  0.1182, -1.8652]]])
>>> m(input)
tensor([[[ 3.5000,  3.5000,  1.6616,  1.4523, -1.1255,  3.5000,  3.5000],
         [ 3.5000,  3.5000, -3.6372,  0.1182, -1.8652,  3.5000,  3.5000]]])
>>> # using different paddings for different sides
>>> m = nn.ConstantPad1d((3, 1), 3.5)
>>> m(input)
tensor([[[ 3.5000,  3.5000,  3.5000,  1.6616,  1.4523, -1.1255,  3.5000],
         [ 3.5000,  3.5000,  3.5000, -3.6372,  0.1182, -1.8652,  3.5000]]])
class torch.nn.ConstantPad2d(padding, value) [source]
 
Pads the input tensor boundaries with a constant value. For N-dimensional padding, use torch.nn.functional.pad().  Parameters 
padding (int, tuple) – the size of the padding. If is int, uses the same padding in all boundaries. If a 4-tuple, uses (padding_left\text{padding\_left} , padding_right\text{padding\_right} , padding_top\text{padding\_top} , padding_bottom\text{padding\_bottom} )    Shape:

 Input: (N,C,Hin,Win)(N, C, H_{in}, W_{in}) 
 
Output: (N,C,Hout,Wout)(N, C, H_{out}, W_{out})  where Hout=Hin+padding_top+padding_bottomH_{out} = H_{in} + \text{padding\_top} + \text{padding\_bottom}  Wout=Win+padding_left+padding_rightW_{out} = W_{in} + \text{padding\_left} + \text{padding\_right}      Examples: >>> m = nn.ConstantPad2d(2, 3.5)
>>> input = torch.randn(1, 2, 2)
>>> input
tensor([[[ 1.6585,  0.4320],
         [-0.8701, -0.4649]]])
>>> m(input)
tensor([[[ 3.5000,  3.5000,  3.5000,  3.5000,  3.5000,  3.5000],
         [ 3.5000,  3.5000,  3.5000,  3.5000,  3.5000,  3.5000],
         [ 3.5000,  3.5000,  1.6585,  0.4320,  3.5000,  3.5000],
         [ 3.5000,  3.5000, -0.8701, -0.4649,  3.5000,  3.5000],
         [ 3.5000,  3.5000,  3.5000,  3.5000,  3.5000,  3.5000],
         [ 3.5000,  3.5000,  3.5000,  3.5000,  3.5000,  3.5000]]])
>>> # using different paddings for different sides
>>> m = nn.ConstantPad2d((3, 0, 2, 1), 3.5)
>>> m(input)
tensor([[[ 3.5000,  3.5000,  3.5000,  3.5000,  3.5000],
         [ 3.5000,  3.5000,  3.5000,  3.5000,  3.5000],
         [ 3.5000,  3.5000,  3.5000,  1.6585,  0.4320],
         [ 3.5000,  3.5000,  3.5000, -0.8701, -0.4649],
         [ 3.5000,  3.5000,  3.5000,  3.5000,  3.5000]]])
class torch.nn.ConstantPad3d(padding, value) [source]
 
Pads the input tensor boundaries with a constant value. For N-dimensional padding, use torch.nn.functional.pad().  Parameters 
padding (int, tuple) – the size of the padding. If is int, uses the same padding in all boundaries. If a 6-tuple, uses (padding_left\text{padding\_left} , padding_right\text{padding\_right} , padding_top\text{padding\_top} , padding_bottom\text{padding\_bottom} , padding_front\text{padding\_front} , padding_back\text{padding\_back} )    Shape:

 Input: (N,C,Din,Hin,Win)(N, C, D_{in}, H_{in}, W_{in}) 
 
Output: (N,C,Dout,Hout,Wout)(N, C, D_{out}, H_{out}, W_{out})  where Dout=Din+padding_front+padding_backD_{out} = D_{in} + \text{padding\_front} + \text{padding\_back}  Hout=Hin+padding_top+padding_bottomH_{out} = H_{in} + \text{padding\_top} + \text{padding\_bottom}  Wout=Win+padding_left+padding_rightW_{out} = W_{in} + \text{padding\_left} + \text{padding\_right}      Examples: >>> m = nn.ConstantPad3d(3, 3.5)
>>> input = torch.randn(16, 3, 10, 20, 30)
>>> output = m(input)
>>> # using different paddings for different sides
>>> m = nn.ConstantPad3d((3, 3, 6, 6, 0, 1), 3.5)
>>> output = m(input)
class torch.nn.CosineEmbeddingLoss(margin=0.0, size_average=None, reduce=None, reduction='mean') [source]
 
Creates a criterion that measures the loss given input tensors x1x_1 , x2x_2  and a Tensor label yy  with values 1 or -1. This is used for measuring whether two inputs are similar or dissimilar, using the cosine distance, and is typically used for learning nonlinear embeddings or semi-supervised learning. The loss function for each sample is:  loss(x,y)={1−cos⁡(x1,x2),if y=1max⁡(0,cos⁡(x1,x2)−margin),if y=−1\text{loss}(x, y) = \begin{cases} 1 - \cos(x_1, x_2), & \text{if } y = 1 \\ \max(0, \cos(x_1, x_2) - \text{margin}), & \text{if } y = -1 \end{cases}  
 Parameters 
 
margin (float, optional) – Should be a number from −1-1  to 11 , 00  to 0.50.5  is suggested. If margin is missing, the default value is 00 . 
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 are 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'
class torch.nn.CosineSimilarity(dim=1, eps=1e-08) [source]
 
Returns cosine similarity between x1x_1  and x2x_2 , 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 
 
dim (int, optional) – Dimension where cosine similarity is computed. Default: 1 
eps (float, optional) – Small value to avoid division by zero. Default: 1e-8     Shape:

 Input1: (∗1,D,∗2)(\ast_1, D, \ast_2)  where D is at position dim
 Input2: (∗1,D,∗2)(\ast_1, D, \ast_2) , same shape as the Input1 Output: (∗1,∗2)(\ast_1, \ast_2) 
   Examples::

>>> input1 = torch.randn(100, 128)
>>> input2 = torch.randn(100, 128)
>>> cos = nn.CosineSimilarity(dim=1, eps=1e-6)
>>> output = cos(input1, input2)
class torch.nn.Dropout(p=0.5, inplace=False) [source]
 
During training, randomly zeroes some of the elements of the input tensor with probability p using samples from a Bernoulli distribution. Each channel will be zeroed out independently on every forward call. This has proven to be an effective technique for regularization and preventing the co-adaptation of neurons as described in the paper Improving neural networks by preventing co-adaptation of feature detectors . Furthermore, the outputs are scaled by a factor of 11−p\frac{1}{1-p}  during training. This means that during evaluation the module simply computes an identity function.  Parameters 
 
p – probability of an element to be zeroed. Default: 0.5 
inplace – If set to True, will do this operation in-place. Default: False
     Shape:

 Input: (∗)(*) . Input can be of any shape Output: (∗)(*) . Output is of the same shape as input    Examples: >>> m = nn.Dropout(p=0.2)
>>> input = torch.randn(20, 16)
>>> output = m(input)
class torch.nn.Dropout2d(p=0.5, 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] ). Each channel will be zeroed out independently on every forward call with probability p using samples from a Bernoulli distribution. Usually the input comes from nn.Conv2d modules. As described in the paper Efficient Object Localization Using Convolutional Networks , if adjacent pixels within feature maps are strongly correlated (as is normally the case in early convolution layers) then i.i.d. dropout will not regularize the activations and will otherwise just result in an effective learning rate decrease. In this case, nn.Dropout2d() will help promote independence between feature maps and should be used instead.  Parameters 
 
p (float, optional) – probability of an element to be zero-ed. 
inplace (bool, optional) – If set to True, will do this operation in-place     Shape:

 Input: (N,C,H,W)(N, C, H, W) 
 Output: (N,C,H,W)(N, C, H, W)  (same shape as input)    Examples: >>> m = nn.Dropout2d(p=0.2)
>>> input = torch.randn(20, 16, 32, 32)
>>> output = m(input)
class torch.nn.Dropout3d(p=0.5, 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] ). Each channel will be zeroed out independently on every forward call with probability p using samples from a Bernoulli distribution. Usually the input comes from nn.Conv3d modules. As described in the paper Efficient Object Localization Using Convolutional Networks , if adjacent pixels within feature maps are strongly correlated (as is normally the case in early convolution layers) then i.i.d. dropout will not regularize the activations and will otherwise just result in an effective learning rate decrease. In this case, nn.Dropout3d() will help promote independence between feature maps and should be used instead.  Parameters 
 
p (float, optional) – probability of an element to be zeroed. 
inplace (bool, optional) – If set to True, will do this operation in-place     Shape:

 Input: (N,C,D,H,W)(N, C, D, H, W) 
 Output: (N,C,D,H,W)(N, C, D, H, W)  (same shape as input)    Examples: >>> m = nn.Dropout3d(p=0.2)
>>> input = torch.randn(20, 16, 4, 32, 32)
>>> output = m(input)
class torch.nn.ELU(alpha=1.0, inplace=False) [source]
 
Applies the element-wise function:  ELU(x)={x, if x>0α∗(exp⁡(x)−1), if x≤0\text{ELU}(x) = \begin{cases} x, & \text{ if } x > 0\\ \alpha * (\exp(x) - 1), & \text{ if } x \leq 0 \end{cases}  
 Parameters 
 
alpha – the α\alpha  value for the ELU formulation. Default: 1.0 
inplace – can optionally do the operation in-place. Default: False
     Shape:

 Input: (N,∗)(N, *)  where * means, any number of additional dimensions Output: (N,∗)(N, *) , same shape as the input     Examples: >>> m = nn.ELU()
>>> input = torch.randn(2)
>>> output = m(input)
classmethod from_pretrained(embeddings, freeze=True, padding_idx=None, max_norm=None, norm_type=2.0, scale_grad_by_freq=False, sparse=False) [source]
 
Creates Embedding instance from given 2-dimensional FloatTensor.  Parameters 
 
embeddings (Tensor) – FloatTensor containing weights for the Embedding. First dimension is being passed to Embedding as num_embeddings, second as embedding_dim. 
freeze (boolean, optional) – If True, the tensor does not get updated in the learning process. Equivalent to embedding.weight.requires_grad = False. Default: True
 
padding_idx (int, optional) – See module initialization documentation. 
max_norm (float, optional) – See module initialization documentation. 
norm_type (float, optional) – See module initialization documentation. Default 2. 
scale_grad_by_freq (boolean, optional) – See module initialization documentation. Default False. 
sparse (bool, optional) – See module initialization documentation.    Examples: >>> # FloatTensor containing pretrained weights
>>> weight = torch.FloatTensor([[1, 2.3, 3], [4, 5.1, 6.3]])
>>> embedding = nn.Embedding.from_pretrained(weight)
>>> # Get embeddings for index 1
>>> input = torch.LongTensor([1])
>>> embedding(input)
tensor([[ 4.0000,  5.1000,  6.3000]])
classmethod from_pretrained(embeddings, freeze=True, max_norm=None, norm_type=2.0, scale_grad_by_freq=False, mode='mean', sparse=False, include_last_offset=False) [source]
 
Creates EmbeddingBag instance from given 2-dimensional FloatTensor.  Parameters 
 
embeddings (Tensor) – FloatTensor containing weights for the EmbeddingBag. First dimension is being passed to EmbeddingBag as ‘num_embeddings’, second as ‘embedding_dim’. 
freeze (boolean, optional) – If True, the tensor does not get updated in the learning process. Equivalent to embeddingbag.weight.requires_grad = False. Default: True
 
max_norm (float, optional) – See module initialization documentation. Default: None
 
norm_type (float, optional) – See module initialization documentation. Default 2. 
scale_grad_by_freq (boolean, optional) – See module initialization documentation. Default False. 
mode (string, optional) – See module initialization documentation. Default: "mean"
 
sparse (bool, optional) – See module initialization documentation. Default: False. 
include_last_offset (bool, optional) – See module initialization documentation. Default: False.    Examples: >>> # FloatTensor containing pretrained weights
>>> weight = torch.FloatTensor([[1, 2.3, 3], [4, 5.1, 6.3]])
>>> embeddingbag = nn.EmbeddingBag.from_pretrained(weight)
>>> # Get embeddings for index 1
>>> input = torch.LongTensor([[1, 0]])
>>> embeddingbag(input)
tensor([[ 2.5000,  3.7000,  4.6500]])
class torch.nn.FractionalMaxPool2d(kernel_size, output_size=None, output_ratio=None, return_indices=False, _random_samples=None) [source]
 
Applies a 2D fractional max pooling over an input signal composed of several input planes. Fractional MaxPooling is described in detail in the paper Fractional MaxPooling by Ben Graham The max-pooling operation is applied in kH×kWkH \times kW  regions by a stochastic step size determined by the target output size. The number of output features is equal to the number of input planes.  Parameters 
 
kernel_size – the size of the window to take a max over. Can be a single number k (for a square kernel of k x k) or a tuple (kh, kw)
 
output_size – the target output size of the image of the form oH x oW. Can be a tuple (oH, oW) or a single number oH for a square image oH x oH
 
output_ratio – If one wants to have an output size as a ratio of the input size, this option can be given. This has to be a number or tuple in the range (0, 1) 
return_indices – if True, will return the indices along with the outputs. Useful to pass to nn.MaxUnpool2d(). Default: False
    Examples >>> # pool of square window of size=3, and target output size 13x12
>>> m = nn.FractionalMaxPool2d(3, output_size=(13, 12))
>>> # pool of square window and target output size being half of input image size
>>> m = nn.FractionalMaxPool2d(3, output_ratio=(0.5, 0.5))
>>> input = torch.randn(20, 16, 50, 32)
>>> output = m(input)
torch.nn.functional.adaptive_avg_pool1d(input, output_size) → Tensor  
Applies a 1D adaptive average pooling over an input signal composed of several input planes. See AdaptiveAvgPool1d for details and output shape.  Parameters 
output_size – the target output size (single integer)
torch.nn.functional.adaptive_avg_pool2d(input, output_size) [source]
 
Applies a 2D adaptive average pooling over an input signal composed of several input planes. See AdaptiveAvgPool2d for details and output shape.  Parameters 
output_size – the target output size (single integer or double-integer tuple)
torch.nn.functional.adaptive_avg_pool3d(input, output_size) [source]
 
Applies a 3D adaptive average pooling over an input signal composed of several input planes. See AdaptiveAvgPool3d for details and output shape.  Parameters 
output_size – the target output size (single integer or triple-integer tuple)
torch.nn.functional.adaptive_max_pool1d(*args, **kwargs)  
Applies a 1D adaptive max pooling over an input signal composed of several input planes. See AdaptiveMaxPool1d for details and output shape.  Parameters 
 
output_size – the target output size (single integer) 
return_indices – whether to return pooling indices. Default: False
torch.nn.functional.adaptive_max_pool2d(*args, **kwargs)  
Applies a 2D adaptive max pooling over an input signal composed of several input planes. See AdaptiveMaxPool2d for details and output shape.  Parameters 
 
output_size – the target output size (single integer or double-integer tuple) 
return_indices – whether to return pooling indices. Default: False
torch.nn.functional.adaptive_max_pool3d(*args, **kwargs)  
Applies a 3D adaptive max pooling over an input signal composed of several input planes. See AdaptiveMaxPool3d for details and output shape.  Parameters 
 
output_size – the target output size (single integer or triple-integer tuple) 
return_indices – whether to return pooling indices. Default: False