shrinath-suresh/blogs-docs-splitted huggingface dataset:
torch.nn.functional.pdist
torch.nn.functional.pdist(input, p=2) -> Tensor
Computes the p-norm distance between every pair of row vectors in
   the input. This is identical to the upper triangular portion,
   excluding the diagonal, of torch.norm(input[:, None] - input,
   dim=2, p=p). This function will be faster if the rows are
   contiguous.
If input has shape N \times M then the output will have shape
   \frac{1}{2} N (N - 1).
This function is equivalent to "scipy.spatial.distance.pdist(input,
   'minkowski', p=p)" if p \in (0, \infty). When p = 0 it is
   equivalent to "scipy.spatial.distance.pdist(input, 'hamming') * M".
   When p = \infty, the closest scipy function is
   "scipy.spatial.distance.pdist(xn, lambda x, y: np.abs(x -
   y).max())".
Parameters:
      * input -- input tensor of shape N \times M.
  * **p** -- p value for the p-norm distance to calculate between
    each vector pair \in [0, \infty].
LogSigmoid
class torch.nn.LogSigmoid
Applies the element-wise function:
  \text{LogSigmoid}(x) = \log\left(\frac{ 1 }{ 1 +
  \exp(-x)}\right)

Shape:
      * Input: (*), where * means any number of dimensions.
  * Output: (*), same shape as the input.

[image]
Examples:
  >>> m = nn.LogSigmoid()
  >>> input = torch.randn(2)
  >>> output = m(input)
SELU
class torch.nn.SELU(inplace=False)
Applied element-wise, as:
  \text{SELU}(x) = \text{scale} * (\max(0,x) + \min(0, \alpha *
  (\exp(x) - 1)))

with \alpha = 1.6732632423543772848170429916717 and \text{scale} =
   1.0507009873554804934193349852946.
Warning:
 When using "kaiming_normal" or "kaiming_normal_" for
 initialisation, "nonlinearity='linear'" should be used instead of
 "nonlinearity='selu'" in order to get Self-Normalizing Neural
 Networks. See "torch.nn.init.calculate_gain()" for more
 information.

More details can be found in the paper Self-Normalizing Neural
   Networks .
Parameters:
      inplace (bool, optional) -- can optionally do the
      operation in-place. Default: "False"
Shape:
      * Input: (*), where * means any number of dimensions.
  * Output: (*), same shape as the input.

[image]
Examples:
  >>> m = nn.SELU()
  >>> input = torch.randn(2)
  >>> output = m(input)
torch.nn.functional.nll_loss
torch.nn.functional.nll_loss(input, target, weight=None, size_average=None, ignore_index=- 100, reduce=None, reduction='mean')
The negative log likelihood loss.
See "NLLLoss" for details.
Parameters:
      * input (Tensor) -- (N, C) where C = number of classes
        or (N, C, H, W) in case of 2D Loss, or (N, C, d_1, d_2, ...,
        d_K) where K \geq 1 in the case of K-dimensional loss. input
        is expected to be log-probabilities.
  * **target** (*Tensor*) -- (N) where each value is 0 \leq
    \text{targets}[i] \leq C-1, or (N, d_1, d_2, ..., d_K) where K
    \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** (*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
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, dim=1), target)
  >>> output.backward()
torch.compile
torch.compile(model=None, , fullgraph=False, dynamic=False, backend='inductor', mode=None, passes=None, *kwargs)
Optimizes given model/function using Dynamo and specified backend
Parameters:
      * model (Callable) -- Module/function to optimize
  * **fullgraph** (*bool*) -- Whether it is ok to break model into
    several subgraphs

  * **dynamic** (*bool*) -- Use dynamic shape tracing

  * **backend** (*str** or **Callable*) -- backend to be used

  * **mode** (*str*) -- Can be either "default", "reduce-overhead"
    or "max-autotune"

  * **passes** (*dict*) -- A dictionary of passes to the backend.
    Passes currently recognized by inductor backend: - static-
    memory - matmul-tune - matmul-padding - triton-autotune -
    triton-bmm - triton-mm - triton-convolution - rematerialize-
    threshold - rematerialize-acc-threshold

Return type:
      Callable
Example:
torch.nn.functional.local_response_norm
torch.nn.functional.local_response_norm(input, size, alpha=0.0001, beta=0.75, k=1.0)
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.
Return type:
      Tensor
ModuleList
class torch.nn.ModuleList(modules=None)
Holds submodules in a list.
"ModuleList" can be indexed like a regular Python list, but modules
   it contains are properly registered, and will be visible by all
   "Module" methods.
Parameters:
      modules (iterable, optional) -- an iterable of modules
      to add
Example:
  class MyModule(nn.Module):
      def __init__(self):
          super(MyModule, self).__init__()
          self.linears = nn.ModuleList([nn.Linear(10, 10) for i in range(10)])

      def forward(self, x):
          # ModuleList can act as an iterable, or be indexed using ints
          for i, l in enumerate(self.linears):
              x = self.linears[i // 2](x) + l(x)
          return x

append(module)
  Appends a given module to the end of the list.

  Parameters:
     **module** (*nn.Module*) -- module to append

  Return type:
     *ModuleList*

extend(modules)
ModuleList
extend(modules)
  Appends modules from a Python iterable to the end of the list.

  Parameters:
     **modules** (*iterable*) -- iterable of modules to append

  Return type:
     *ModuleList*

insert(index, module)
  Insert a given module before a given index in the list.

  Parameters:
     * **index** (*int*) -- index to insert.

     * **module** (*nn.Module*) -- module to insert
torch.nn.functional.adaptive_max_pool1d
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"
FakeQuantize
class torch.quantization.fake_quantize.FakeQuantize(observer=, quant_min=None, quant_max=None, **observer_kwargs)
Simulate the quantize and dequantize operations in training time.
   The output of this module is given by:
  x_out = (
    clamp(round(x/scale + zero_point), quant_min, quant_max) - zero_point
  ) * scale



"scale" defines the scale factor used for quantization.


"zero_point" specifies the quantized value to which 0 in floating
     point maps to


"fake_quant_enabled" controls the application of fake
     quantization on tensors, note that statistics can still be
     updated.


"observer_enabled" controls statistics collection on tensors


"dtype" specifies the quantized dtype that is being emulated with
     fake-quantization,
        allowable values are torch.qint8 and torch.quint8.


Parameters:
torch.adjoint
torch.adjoint(Tensor) -> Tensor
Returns a view of the tensor conjugated and with the last two
   dimensions transposed.
"x.adjoint()" is equivalent to "x.transpose(-2, -1).conj()" for
   complex tensors and to "x.transpose(-2, -1)" for real tensors.
Example::
      >>> x = torch.arange(4, dtype=torch.float)
      >>> A = torch.complex(x, x).reshape(2, 2)
      >>> A
      tensor([[0.+0.j, 1.+1.j],
              [2.+2.j, 3.+3.j]])
      >>> A.adjoint()
      tensor([[0.-0.j, 2.-2.j],
              [1.-1.j, 3.-3.j]])
      >>> (A.adjoint() == A.mH).all()
      tensor(True)
Softmin
class torch.nn.Softmin(dim=None)
Applies the Softmin function to an n-dimensional input Tensor
   rescaling them so that the elements of the n-dimensional output
   Tensor lie in the range [0, 1] and sum to 1.
Softmin is defined as:
  \text{Softmin}(x_{i}) = \frac{\exp(-x_i)}{\sum_j \exp(-x_j)}

Shape:
      * Input: (*) where *** means, any number of additional
        dimensions
  * Output: (*), same shape as the input

Parameters:
      dim (int) -- A dimension along which Softmin will be
      computed (so every slice along dim will sum to 1).
Returns:
      a Tensor of the same dimension and shape as the input, with
      values in the range [0, 1]
Return type:
      None
Examples:
  >>> m = nn.Softmin(dim=1)
  >>> input = torch.randn(2, 3)
  >>> output = m(input)
UninitializedParameter
class torch.nn.parameter.UninitializedParameter(requires_grad=True, device=None, dtype=None)
A parameter that is not initialized.
Uninitialized Parameters are a a special case of
   "torch.nn.Parameter" where the shape of the data is still unknown.
Unlike a "torch.nn.Parameter", uninitialized parameters hold no
   data and attempting to access some properties, like their shape,
   will throw a runtime error. The only operations that can be
   performed on a uninitialized parameter are changing its datatype,
   moving it to a different device and converting it to a regular
   "torch.nn.Parameter".
The default device or dtype to use when the parameter is
   materialized can be set during construction using e.g.
   "device='cuda'".
cls_to_become
  alias of "Parameter"
torch.linalg.tensorinv
torch.linalg.tensorinv(A, ind=2, *, out=None) -> Tensor
Computes the multiplicative inverse of "torch.tensordot()".
If m is the product of the first "ind" dimensions of "A" and n
   is the product of the rest of the dimensions, this function expects
   m and n to be equal. If this is the case, it computes a tensor
   X such that tensordot("A", X, "ind") is the identity matrix
   in dimension m. X will have the shape of "A" but with the first
   "ind" dimensions pushed back to the end
  X.shape == A.shape[ind:] + A.shape[:ind]

Supports input of float, double, cfloat and cdouble dtypes.
Note:
 When "A" is a *2*-dimensional tensor and "ind"*= 1*, this
 function computes the (multiplicative) inverse of "A" (see
 "torch.linalg.inv()").

Note:
 Consider using "torch.linalg.tensorsolve()" if possible for
 multiplying a tensor on the left by the tensor inverse, as:
linalg.tensorsolve(A, B) == torch.tensordot(linalg.tensorinv(A), B)  # When B is a tensor with shape A.shape[:B.ndim]
 It is always preferred to use "tensorsolve()" when possible, as
 it is faster and more numerically stable than computing the
 pseudoinverse explicitly.

See also:
 "torch.linalg.tensorsolve()" computes
 *torch.tensordot(tensorinv(*"A"*), *"B"*)*.

Parameters:
      * A (Tensor) -- tensor to invert. Its shape must satisfy
        prod("A".shape[:"ind"]) == prod("A".shape["ind":]).
  * **ind** (*int*) -- index at which to compute the inverse of
    "torch.tensordot()". Default: *2*.

Keyword Arguments:
      out (Tensor, optional) -- output tensor. Ignored if
      None. Default: None.
Raises:
      RuntimeError -- if the reshaped "A" is not invertible or the
      product of the first     "ind" dimensions is not equal to the
      product of the rest.
Examples:
product of the rest.
Examples:
  >>> A = torch.eye(4 * 6).reshape((4, 6, 8, 3))
  >>> Ainv = torch.linalg.tensorinv(A, ind=2)
  >>> Ainv.shape
  torch.Size([8, 3, 4, 6])
  >>> B = torch.randn(4, 6)
  >>> torch.allclose(torch.tensordot(Ainv, B), torch.linalg.tensorsolve(A, B))
  True

  >>> A = torch.randn(4, 4)
  >>> Atensorinv = torch.linalg.tensorinv(A, ind=1)
  >>> Ainv = torch.linalg.inverse(A)
  >>> torch.allclose(Atensorinv, Ainv)
  True
torch.randint
torch.randint(low=0, high, size, *, generator=None, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) -> Tensor
Returns a tensor filled with random integers generated uniformly
   between "low" (inclusive) and "high" (exclusive).
The shape of the tensor is defined by the variable argument "size".
Note:
 With the global dtype default ("torch.float32"), this function
 returns a tensor with dtype "torch.int64".

Parameters:
      * low (int, optional) -- Lowest integer to be drawn
        from the distribution. Default: 0.
  * **high** (*int*) -- One above the highest integer to be drawn
    from the distribution.

  * **size** (*tuple*) -- a tuple defining the shape of the output
    tensor.

Keyword Arguments:
      * generator ("torch.Generator", optional) -- a pseudorandom
        number generator for sampling
  * **out** (*Tensor**, **optional*) -- the output tensor.
dtype (torch.dtype, optional) -- if "None", this
        function returns a tensor with dtype "torch.int64".


layout ("torch.layout", optional) -- the desired layout of
    returned Tensor. Default: "torch.strided".


device ("torch.device", optional) -- the desired device of
    returned tensor. Default: if "None", uses the current device
    for the default tensor type (see
    "torch.set_default_tensor_type()"). "device" will be the CPU
    for CPU tensor types and the current CUDA device for CUDA
    tensor types.


requires_grad (bool, optional) -- If autograd should
    record operations on the returned tensor. Default: "False".




Example:
  >>> torch.randint(3, 5, (3,))
  tensor([4, 3, 4])


  >>> torch.randint(10, (2, 2))
  tensor([[0, 2],
          [5, 5]])


  >>> torch.randint(3, 10, (2, 2))
  tensor([[4, 5],
          [6, 7]])
get_default_qconfig_mapping
class torch.ao.quantization.qconfig_mapping.get_default_qconfig_mapping(backend='x86', version=0)
Return the default QConfigMapping for post training quantization.
Parameters:
      * backend (***) -- the quantization backend for the default
        qconfig mapping, should be one of ["x86" (default), "fbgemm",
        "qnnpack", "onednn"]
  * **version** (***) -- the version for the default qconfig
    mapping

Return type:
      QConfigMapping
torch.any
torch.any(input) -> Tensor
Tests if any element in "input" evaluates to True.
Note:
 This function matches the behaviour of NumPy in returning output
 of dtype *bool* for all supported dtypes except *uint8*. For
 *uint8* the dtype of output is *uint8* itself.

Example:
  >>> a = torch.rand(1, 2).bool()
  >>> a
  tensor([[False, True]], dtype=torch.bool)
  >>> torch.any(a)
  tensor(True, dtype=torch.bool)
  >>> a = torch.arange(0, 3)
  >>> a
  tensor([0, 1, 2])
  >>> torch.any(a)
  tensor(True)

torch.any(input, dim, keepdim=False, *, out=None) -> Tensor
For each row of "input" in the given dimension "dim", returns
   True if any element in the row evaluate to True and False
   otherwise.
If "keepdim" is "True", the output tensor is of the same size as
   "input" except in the dimension "dim" where it is of size 1.
   Otherwise, "dim" is squeezed (see "torch.squeeze()"), resulting in
the output tensor having 1 fewer dimension than "input".
Parameters:
      * input (Tensor) -- the input tensor.
  * **dim** (*int*) -- the dimension to reduce.

  * **keepdim** (*bool*) -- whether the output tensor has "dim"
    retained or not.

Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> a = torch.randn(4, 2) < 0
  >>> a
  tensor([[ True,  True],
          [False,  True],
          [ True,  True],
          [False, False]])
  >>> torch.any(a, 1)
  tensor([ True,  True,  True, False])
  >>> torch.any(a, 0)
  tensor([True, True])
torch.Tensor.sparse_resize_
Tensor.sparse_resize_(size, sparse_dim, dense_dim) -> Tensor
Resizes "self" sparse tensor to the desired size and the number of
   sparse and dense dimensions.
Note:
 If the number of specified elements in "self" is zero, then
 "size", "sparse_dim", and "dense_dim" can be any size and
 positive integers such that "len(size) == sparse_dim +
 dense_dim".If "self" specifies one or more elements, however,
 then each dimension in "size" must not be smaller than the
 corresponding dimension of "self", "sparse_dim" must equal the
 number of sparse dimensions in "self", and "dense_dim" must equal
 the number of dense dimensions in "self".

Warning:
 Throws an error if "self" is not a sparse tensor.

Parameters:
      * size (torch.Size) -- the desired size. If "self" is non-
        empty sparse tensor, the desired size cannot be smaller than
        the original size.
torch.linalg.multi_dot
torch.linalg.multi_dot(tensors, *, out=None)
Efficiently multiplies two or more matrices by reordering the
   multiplications so that the fewest arithmetic operations are
   performed.
Supports inputs of float, double, cfloat and cdouble dtypes. This
   function does not support batched inputs.
Every tensor in "tensors" must be 2D, except for the first and last
   which may be 1D. If the first tensor is a 1D vector of shape (n,)
   it is treated as a row vector of shape (1, n), similarly if the
   last tensor is a 1D vector of shape (n,) it is treated as a
   column vector of shape (n, 1).
If the first and last tensors are matrices, the output will be a
   matrix. However, if either is a 1D vector, then the output will be
   a 1D vector.
Differences with numpy.linalg.multi_dot:

Unlike numpy.linalg.multi_dot, the first and last tensors must
     either be 1D or 2D whereas NumPy allows them to be nD

Warning:
Warning:
 This function does not broadcast.

Note:
 This function is implemented by chaining "torch.mm()" calls after
 computing the optimal matrix multiplication order.

Note:
 The cost of multiplying two matrices with shapes *(a, b)* and
 *(b, c)* is *a * b * c*. Given matrices *A*, *B*, *C* with shapes
 *(10, 100)*, *(100, 5)*, *(5, 50)* respectively, we can calculate
 the cost of different multiplication orders as follows:

    \begin{align*} \operatorname{cost}((AB)C) &= 10 \times 100
    \times 5 + 10 \times 5 \times 50 = 7500 \\
    \operatorname{cost}(A(BC)) &= 10 \times 100 \times 50 + 100
    \times 5 \times 50 = 75000 \end{align*}

 In this case, multiplying *A* and *B* first followed by *C* is 10
 times faster.

Parameters:
      tensors (Sequence[Tensor]) -- two or more tensors to
      multiply. The first and last tensors may be 1D or 2D. Every
      other tensor must be 2D.
Keyword Arguments:
Keyword Arguments:
      out (Tensor, optional) -- output tensor. Ignored if
      None. Default: None.
Examples:
  >>> from torch.linalg import multi_dot

  >>> multi_dot([torch.tensor([1, 2]), torch.tensor([2, 3])])
  tensor(8)
  >>> multi_dot([torch.tensor([[1, 2]]), torch.tensor([2, 3])])
  tensor([8])
  >>> multi_dot([torch.tensor([[1, 2]]), torch.tensor([[2], [3]])])
  tensor([[8]])

  >>> A = torch.arange(2 * 3).view(2, 3)
  >>> B = torch.arange(3 * 2).view(3, 2)
  >>> C = torch.arange(2 * 2).view(2, 2)
  >>> multi_dot((A, B, C))
  tensor([[ 26,  49],
          [ 80, 148]])
torch.fake_quantize_per_tensor_affine
torch.fake_quantize_per_tensor_affine(input, scale, zero_point, quant_min, quant_max) -> Tensor
Returns a new tensor with the data in "input" fake quantized using
   "scale", "zero_point", "quant_min" and "quant_max".
  \text{output} = min(     \text{quant\_max},     max(
  \text{quant\_min},         \text{std::nearby\_int}(\text{input}
  / \text{scale}) + \text{zero\_point}     ) )

Parameters:
      * input (Tensor) -- the input value(s), "torch.float32"
        tensor
  * **scale** (double scalar or "float32" Tensor) -- quantization
    scale

  * **zero_point** (int64 scalar or "int32" Tensor) --
    quantization zero_point

  * **quant_min** (*int64*) -- lower bound of the quantized domain

  * **quant_max** (*int64*) -- upper bound of the quantized domain

Returns:
      A newly fake_quantized "torch.float32" tensor
Return type:
      Tensor
Example:
Return type:
      Tensor
Example:
  >>> x = torch.randn(4)
  >>> x
  tensor([ 0.0552,  0.9730,  0.3973, -1.0780])
  >>> torch.fake_quantize_per_tensor_affine(x, 0.1, 0, 0, 255)
  tensor([0.1000, 1.0000, 0.4000, 0.0000])
  >>> torch.fake_quantize_per_tensor_affine(x, torch.tensor(0.1), torch.tensor(0), 0, 255)
  tensor([0.6000, 0.4000, 0.0000, 0.0000])
torch.Tensor.view
Tensor.view(*shape) -> Tensor
Returns a new tensor with the same data as the "self" tensor but of
   a different "shape".
The returned tensor shares the same data and must have the same
   number of elements, but may have a different size. For a tensor to
   be viewed, the new view size must be compatible with its original
   size and stride, i.e., each new view dimension must either be a
   subspace of an original dimension, or only span across original
   dimensions d, d+1, \dots, d+k that satisfy the following
   contiguity-like condition that \forall i = d, \dots, d+k-1,
  \text{stride}[i] = \text{stride}[i+1] \times \text{size}[i+1]

Otherwise, it will not be possible to view "self" tensor as "shape"
   without copying it (e.g., via "contiguous()"). When it is unclear
   whether a "view()" can be performed, it is advisable to use
   "reshape()", which returns a view if the shapes are compatible, and
copies (equivalent to calling "contiguous()") otherwise.
Parameters:
      shape (torch.Size or int...) -- the desired size
Example:
  >>> x = torch.randn(4, 4)
  >>> x.size()
  torch.Size([4, 4])
  >>> y = x.view(16)
  >>> y.size()
  torch.Size([16])
  >>> z = x.view(-1, 8)  # the size -1 is inferred from other dimensions
  >>> z.size()
  torch.Size([2, 8])

  >>> a = torch.randn(1, 2, 3, 4)
  >>> a.size()
  torch.Size([1, 2, 3, 4])
  >>> b = a.transpose(1, 2)  # Swaps 2nd and 3rd dimension
  >>> b.size()
  torch.Size([1, 3, 2, 4])
  >>> c = a.view(1, 3, 2, 4)  # Does not change tensor layout in memory
  >>> c.size()
  torch.Size([1, 3, 2, 4])
  >>> torch.equal(b, c)
  False

view(dtype) -> Tensor
Returns a new tensor with the same data as the "self" tensor but of
   a different "dtype".
If the element size of "dtype" is different than that of
"self.dtype", then the size of the last dimension of the output
   will be scaled proportionally.  For instance, if "dtype" element
   size is twice that of "self.dtype", then each pair of elements in
   the last dimension of "self" will be combined, and the size of the
   last dimension of the output will be half that of "self". If
   "dtype" element size is half that of "self.dtype", then each
   element in the last dimension of "self" will be split in two, and
   the size of the last dimension of the output will be double that of
   "self". For this to be possible, the following conditions must be
   true:
  * "self.dim()" must be greater than 0.

  * "self.stride(-1)" must be 1.

Additionally, if the element size of "dtype" is greater than that
   of "self.dtype", the following conditions must be true as well:
  * "self.size(-1)" must be divisible by the ratio between the
    element sizes of the dtypes.

  * "self.storage_offset()" must be divisible by the ratio between