shrinath-suresh/blogs-docs-splitted huggingface dataset:
torch.nn.functional.linear
torch.nn.functional.linear(input, weight, bias=None) -> Tensor
Applies a linear transformation to the incoming data: y = xA^T + b.
This operation supports 2-D "weight" with sparse layout
Warning:
 Sparse support is a beta feature and some layout(s)/dtype/device
 combinations may not be supported, or may not have autograd
 support. If you notice missing functionality please open a
 feature request.

This operator supports TensorFloat32.
Shape:
  * Input: (*, in\_features) where *** means any number of
    additional dimensions, including none

  * Weight: (out\_features, in\_features) or (in\_features)

  * Bias: (out\_features) or ()

  * Output: (*, out\_features) or (*), based on the shape of the
    weight
torch.nansum
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 ints**, **optional*) -- the
    dimension or dimensions to reduce. If "None", all dimensions
    are reduced.

  * **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)
torch.t
torch.t(input) -> Tensor
Expects "input" to be <= 2-D tensor and transposes dimensions 0 and
   1.
0-D and 1-D tensors are returned as is. When input is a 2-D tensor
   this is equivalent to "transpose(input, 0, 1)".
Parameters:
      input (Tensor) -- the input tensor.
Example:
  >>> x = torch.randn(())
  >>> x
  tensor(0.1995)
  >>> torch.t(x)
  tensor(0.1995)
  >>> x = torch.randn(3)
  >>> x
  tensor([ 2.4320, -0.4608,  0.7702])
  >>> torch.t(x)
  tensor([ 2.4320, -0.4608,  0.7702])
  >>> x = torch.randn(2, 3)
  >>> x
  tensor([[ 0.4875,  0.9158, -0.5872],
          [ 0.3938, -0.6929,  0.6932]])
  >>> torch.t(x)
  tensor([[ 0.4875,  0.3938],
          [ 0.9158, -0.6929],
          [-0.5872,  0.6932]])

See also "torch.transpose()".
torch.nn.functional.binary_cross_entropy
torch.nn.functional.binary_cross_entropy(input, target, weight=None, size_average=None, reduce=None, reduction='mean')
Function that measures the Binary Cross Entropy between the target
   and input probabilities.
See "BCELoss" for details.
Parameters:
      * input (Tensor) -- Tensor of arbitrary shape as
        probabilities.
  * **target** (*Tensor*) -- Tensor of the same shape as input
    with values between 0 and 1.

  * **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** (*str**, **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'"

Return type:
      Tensor
Examples:
torch.fmin
torch.fmin(input, other, *, out=None) -> Tensor
Computes the element-wise minimum of "input" and "other".
This is like "torch.minimum()" except it handles NaNs differently:
   if exactly one of the two elements being compared is a NaN then the
   non-NaN element is taken as the minimum. Only if both elements are
   NaN is NaN propagated.
This function is a wrapper around C++'s "std::fmin" and is similar
   to NumPy's "fmin" function.
Supports broadcasting to a common shape, type promotion, and
   integer and floating-point inputs.
Parameters:
      * input (Tensor) -- the input tensor.
  * **other** (*Tensor*) -- the second input tensor

Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> a = torch.tensor([2.2, float('nan'), 2.1, float('nan')])
  >>> b = torch.tensor([-9.3, 0.1, float('nan'), float('nan')])
  >>> torch.fmin(a, b)
  tensor([-9.3000, 0.1000, 2.1000,    nan])
torch.min
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)
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:
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()".
CosineAnnealingWarmRestarts
class torch.optim.lr_scheduler.CosineAnnealingWarmRestarts(optimizer, T_0, T_mult=1, eta_min=0, last_epoch=- 1, verbose=False)
Set the learning rate of each parameter group using a cosine
   annealing schedule, where \eta_{max} is set to the initial lr,
   T_{cur} is the number of epochs since the last restart and T_{i} is
   the number of epochs between two warm restarts in SGDR:
  \eta_t = \eta_{min} + \frac{1}{2}(\eta_{max} -
  \eta_{min})\left(1 +
  \cos\left(\frac{T_{cur}}{T_{i}}\pi\right)\right)

When T_{cur}=T_{i}, set \eta_t = \eta_{min}. When T_{cur}=0 after
   restart, set \eta_t=\eta_{max}.
It has been proposed in SGDR: Stochastic Gradient Descent with Warm
   Restarts.
Parameters:
      * optimizer (Optimizer) -- Wrapped optimizer.
  * **T_0** (*int*) -- Number of iterations for the first restart.

  * **T_mult** (*int**, **optional*) -- A factor increases T_{i}
    after a restart. Default: 1.
after a restart. Default: 1.
  * **eta_min** (*float**, **optional*) -- Minimum learning rate.
    Default: 0.

  * **last_epoch** (*int**, **optional*) -- The index of last
    epoch. Default: -1.

  * **verbose** (*bool*) -- If "True", prints a message to stdout
    for each update. Default: "False".

get_last_lr()
  Return last computed learning rate by current scheduler.

load_state_dict(state_dict)
  Loads the schedulers state.

  Parameters:
     **state_dict** (*dict*) -- scheduler state. Should be an
     object returned from a call to "state_dict()".

print_lr(is_verbose, group, lr, epoch=None)
  Display the current learning rate.

state_dict()
  Returns the state of the scheduler as a "dict".

  It contains an entry for every variable in self.__dict__ which
  is not the optimizer.

step(epoch=None)
  Step could be called after every batch update

  -[ Example ]-
-[ Example ]-
  >>> scheduler = CosineAnnealingWarmRestarts(optimizer, T_0, T_mult)
  >>> iters = len(dataloader)
  >>> for epoch in range(20):
  >>>     for i, sample in enumerate(dataloader):
  >>>         inputs, labels = sample['inputs'], sample['labels']
  >>>         optimizer.zero_grad()
  >>>         outputs = net(inputs)
  >>>         loss = criterion(outputs, labels)
  >>>         loss.backward()
  >>>         optimizer.step()
  >>>         scheduler.step(epoch + i / iters)

  This function can be called in an interleaved way.

  -[ Example ]-

  >>> scheduler = CosineAnnealingWarmRestarts(optimizer, T_0, T_mult)
  >>> for epoch in range(20):
  >>>     scheduler.step()
  >>> scheduler.step(26)
  >>> scheduler.step() # scheduler.step(27), instead of scheduler(20)
upsample_bilinear
class torch.ao.nn.quantized.functional.upsample_bilinear(input, size=None, scale_factor=None)
Upsamples the input, using bilinear upsampling.
Warning:
 This function is deprecated in favor of
 "torch.nn.quantized.functional.interpolate()". This is equivalent
 with "nn.quantized.functional.interpolate(..., mode='bilinear',
 align_corners=True)".

Note:
 The input quantization parameters propagate to the output.

Note:
 Only 2D inputs are supported

Parameters:
      * input (Tensor) -- quantized input
  * **size** (*int** or **Tuple**[**int**, **int**]*) -- output
    spatial size.

  * **scale_factor** (*int** or **Tuple**[**int**, **int**]*) --
    multiplier for spatial size
torch.unflatten
torch.unflatten(input, dim, sizes) -> Tensor
Expands a dimension of the input tensor over multiple dimensions.
See also:
 "torch.flatten()" the inverse of this function. It coalesces
 several dimensions into one.

Parameters:
      * input (Tensor) -- the input tensor.
  * **dim** (*int*) -- Dimension to be unflattened, specified as
    an index into "input.shape".

  * **sizes** (*Tuple**[**int**]*) -- New shape of the unflattened
    dimension. One of its elements can be *-1* in which case the
    corresponding output dimension is inferred. Otherwise, the
    product of "sizes" *must* equal "input.shape[dim]".

Returns:
      A View of input with the specified dimension unflattened.
Examples::
      >>> torch.unflatten(torch.randn(3, 4, 1), 1, (2, 2)).shape
      torch.Size([3, 2, 2, 1])
      >>> torch.unflatten(torch.randn(3, 4, 1), 1, (-1, 2)).shape
      torch.Size([3, 2, 2, 1])
torch.nn.functional.interpolate
torch.nn.functional.interpolate(input, size=None, scale_factor=None, mode='nearest', align_corners=None, recompute_scale_factor=None, antialias=False)
Down/up samples the input to either the given "size" or the given
   "scale_factor"
The algorithm used for interpolation is determined by "mode".
Currently temporal, spatial and volumetric sampling are supported,
   i.e. expected inputs are 3-D, 4-D or 5-D in shape.
The input dimensions are interpreted in the form: mini-batch x
   channels x [optional depth] x [optional height] x width.
The modes available for resizing are: nearest, linear (3D-
   only), bilinear, bicubic (4D-only), trilinear (5D-only),
   area, nearest-exact
Parameters:
      * input (Tensor) -- the input tensor
  * **size** (*int** or **Tuple**[**int**] or **Tuple**[**int**,
    **int**] or **Tuple**[**int**, **int**, **int**]*) -- output
    spatial size.
spatial size.
  * **scale_factor** (*float** or **Tuple**[**float**]*) --
    multiplier for spatial size. If *scale_factor* is a tuple, its
    length has to match the number of spatial dimensions;
    *input.dim() - 2*.

  * **mode** (*str*) -- algorithm used for upsampling: "'nearest'"
    | "'linear'" | "'bilinear'" | "'bicubic'" | "'trilinear'" |
    "'area'" | "'nearest-exact'". Default: "'nearest'"

  * **align_corners** (*bool**, **optional*) -- Geometrically, we
    consider the pixels of the input and output as squares rather
    than points. If set to "True", the input and output tensors
    are aligned by the center points of their corner pixels,
    preserving the values at the corner pixels. If set to "False",
    the input and output tensors are aligned by the corner points
    of their corner pixels, and the interpolation uses edge value
    padding for out-of-boundary values, making this operation
independent of input size when "scale_factor" is kept the
        same. This only has an effect when "mode" is "'linear'",
        "'bilinear'", "'bicubic'" or "'trilinear'". Default: "False"
  * **recompute_scale_factor** (*bool**, **optional*) -- recompute
    the scale_factor for use in the interpolation calculation. If
    *recompute_scale_factor* is "True", then *scale_factor* must
    be passed in and *scale_factor* is used to compute the output
    *size*. The computed output *size* will be used to infer new
    scales for the interpolation. Note that when *scale_factor* is
    floating-point, it may differ from the recomputed
    *scale_factor* due to rounding and precision issues. If
    *recompute_scale_factor* is "False", then *size* or
    *scale_factor* will be used directly for interpolation.
    Default: "None".

  * **antialias** (*bool**, **optional*) -- flag to apply anti-
aliasing. Default: "False". Using anti-alias option together
        with "align_corners=False", interpolation result would match
        Pillow result for downsampling operation. Supported modes:
        "'bilinear'", "'bicubic'".
Return type:
      Tensor
Note:
 With "mode='bicubic'", it's possible to cause overshoot, in other
 words it can produce negative values or values greater than 255
 for images. Explicitly call "result.clamp(min=0, max=255)" if you
 want to reduce the overshoot when displaying the image.

Note:
 Mode "mode='nearest-exact'" matches Scikit-Image and PIL nearest
 neighbours interpolation algorithms and fixes known issues with
 "mode='nearest'". This mode is introduced to keep backward
 compatibility. Mode "mode='nearest'" matches buggy OpenCV's
 "INTER_NEAREST" interpolation algorithm.

Note:
 This operation may produce nondeterministic gradients when given
 tensors on a CUDA device. See Reproducibility for more
LPPool2d
class torch.nn.LPPool2d(norm_type, kernel_size, stride=None, ceil_mode=False)
Applies a 2D power-average pooling over an input signal composed of
   several input planes.
On each window, the function computed is:
  f(X) = \sqrt[p]{\sum_{x \in X} x^{p}}



At p = \infty, one gets Max Pooling


At p = 1, one gets Sum Pooling (which is proportional to average
     pooling)


The parameters "kernel_size", "stride" can either be:
  * a single "int" -- in which case the same value is used for the
    height and width dimension

  * a "tuple" of two ints -- in which case, the first *int* is
    used for the height dimension, and the second *int* for the
    width dimension

Note:
 If the sum to the power of *p* is zero, the gradient of this
 function is not defined. This implementation will set the
 gradient to zero in this case.

Parameters:
      * kernel_size (Union[int, Tuple[int*,
int]*]) -- the size of the window
  * **stride** (*Union**[**int**, **Tuple**[**int**, **int**]**]*)
    -- the stride of the window. Default value is "kernel_size"

  * **ceil_mode** (*bool*) -- when True, will use *ceil* instead
    of *floor* to compute the output shape

Shape:
      * Input: (N, C, H_{in}, W_{in})
  * Output: (N, C, H_{out}, W_{out}), where

       H_{out} = \left\lfloor\frac{H_{in} -
       \text{kernel\_size}[0]}{\text{stride}[0]} + 1\right\rfloor

       W_{out} = \left\lfloor\frac{W_{in} -
       \text{kernel\_size}[1]}{\text{stride}[1]} + 1\right\rfloor

Examples:
  >>> # power-2 pool of square window of size=3, stride=2
  >>> m = nn.LPPool2d(2, 3, stride=2)
  >>> # pool of non-square window of power 1.2
  >>> m = nn.LPPool2d(1.2, (3, 2), stride=(2, 1))
  >>> input = torch.randn(20, 16, 50, 32)
  >>> output = m(input)
PixelShuffle
class torch.nn.PixelShuffle(upscale_factor)
Rearranges elements in a tensor of shape (, C \times r^2, H, W) to
   a tensor of shape (, C, H \times r, W \times r), where r is an
   upscale factor.
This is useful for implementing efficient sub-pixel convolution
   with a stride of 1/r.
See the paper: Real-Time Single Image and Video Super-Resolution
   Using an Efficient Sub-Pixel Convolutional Neural Network by Shi
   et. al (2016) for more details.
Parameters:
      upscale_factor (int) -- factor to increase spatial
      resolution by
Shape:
      * Input: (*, C_{in}, H_{in}, W_{in}), where * is zero or more
        batch dimensions
  * Output: (*, C_{out}, H_{out}, W_{out}), where

  C_{out} = C_{in} \div \text{upscale\_factor}^2

  H_{out} = H_{in} \times \text{upscale\_factor}

  W_{out} = W_{in} \times \text{upscale\_factor}

Examples:
  >>> pixel_shuffle = nn.PixelShuffle(3)
  >>> input = torch.randn(1, 9, 4, 4)
Conv3d
class torch.ao.nn.qat.Conv3d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros', qconfig=None, device=None, dtype=None)
A Conv3d module attached with FakeQuantize modules for weight, used
   for quantization aware training.
We adopt the same interface as torch.nn.Conv3d, please see https
   ://pytorch.org/docs/stable/nn.html?highlight=conv3d#torch.nn.Conv3d
   for documentation.
Similar to torch.nn.Conv3d, with FakeQuantize modules initialized
   to default.
Variables:
      weight_fake_quant -- fake quant module for weight
PoissonNLLLoss
class torch.nn.PoissonNLLLoss(log_input=True, full=False, size_average=None, eps=1e-08, reduce=None, reduction='mean')
Negative log likelihood loss with Poisson distribution of target.
The loss can be described as:
  \text{target} \sim \mathrm{Poisson}(\text{input})
  \text{loss}(\text{input}, \text{target}) = \text{input} -
  \text{target} * \log(\text{input})                             +
  \log(\text{target!})

The last term can be omitted or approximated with Stirling formula.
   The approximation is used for target values more than 1. For
   targets less or equal to 1 zeros are added to the loss.
Parameters:
      * log_input (bool, optional) -- if "True" the loss is
        computed as \exp(\text{input}) - \text{target}\text{input},
        if "False" the loss is \text{input} -
        \text{target}\log(\text{input}+\text{eps}).
  * **full** (*bool**, **optional*) --
full (bool, optional) --
whether to compute full loss, i. e. to add the Stirling
approximation term

   \text{target}*\log(\text{target}) - \text{target} + 0.5 *
   \log(2\pi\text{target}).



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"


eps (float, optional) -- Small value to avoid
    evaluation of \log(0) when "log_input = False". Default: 1e-8


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** (*str**, **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:
  >>> loss = nn.PoissonNLLLoss()
  >>> log_input = torch.randn(5, 2, requires_grad=True)
  >>> target = torch.randn(5, 2)
  >>> output = loss(log_input, target)
  >>> output.backward()

Shape:
      * Input: (*), where * means any number of dimensions.
  * Target: (*), same shape as the input.
torch.bincount
torch.bincount(input, weights=None, minlength=0) -> Tensor
Count the frequency of each value in an array of non-negative ints.
The number of bins (size 1) is one larger than the largest value in
   "input" unless "input" is empty, in which case the result is a
   tensor of size 0. If "minlength" is specified, the number of bins
   is at least "minlength" and if "input" is empty, then the result is
   tensor of size "minlength" filled with zeros. If "n" is the value
   at position "i", "out[n] += weights[i]" if "weights" is specified
   else "out[n] += 1".
Note:
 This operation may produce nondeterministic gradients when given
 tensors on a CUDA device. See Reproducibility for more
 information.

Parameters:
      * input (Tensor) -- 1-d int tensor
  * **weights** (*Tensor*) -- optional, weight for each value in
    the input tensor. Should be of same size as input tensor.
minlength (int) -- optional, minimum number of bins.
        Should be non-negative.

Returns:
      a tensor of shape "Size([max(input) + 1])" if "input" is non-
      empty, else "Size(0)"
Return type:
      output (Tensor)
Example:
  >>> input = torch.randint(0, 8, (5,), dtype=torch.int64)
  >>> weights = torch.linspace(0, 1, steps=5)
  >>> input, weights
  (tensor([4, 3, 6, 3, 4]),
   tensor([ 0.0000,  0.2500,  0.5000,  0.7500,  1.0000])

  >>> torch.bincount(input)
  tensor([0, 0, 0, 2, 2, 0, 1])

  >>> input.bincount(weights)
  tensor([0.0000, 0.0000, 0.0000, 1.0000, 1.0000, 0.0000, 0.5000])
torch.tril
torch.tril(input, diagonal=0, *, out=None) -> Tensor
Returns the lower triangular part of the matrix (2-D tensor) or
   batch of matrices "input", the other elements of the result tensor
   "out" are set to 0.
The lower triangular part of the matrix is defined as the elements
   on and below the diagonal.
The argument "diagonal" controls which diagonal to consider. If
   "diagonal" = 0, all elements on and below the main diagonal are
   retained. A positive value includes just as many diagonals above
   the main diagonal, and similarly a negative value excludes just as
   many diagonals below the main diagonal. The main diagonal are the
   set of indices \lbrace (i, i) \rbrace for i \in [0, \min{d_{1},
   d_{2}} - 1] where d_{1}, d_{2} are the dimensions of the matrix.
Parameters:
      * input (Tensor) -- the input tensor.
  * **diagonal** (*int**, **optional*) -- the diagonal to consider

Keyword Arguments: