shrinath-suresh/blogs-docs-splitted huggingface dataset:
dim (int, optional) -- the dimension to find the kth
        value along

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



Keyword Arguments:
      out (tuple, optional) -- the output tuple of (Tensor,
      LongTensor) can be optionally given to be used as output buffers
Example:
  >>> x = torch.arange(1., 6.)
  >>> x
  tensor([ 1.,  2.,  3.,  4.,  5.])
  >>> torch.kthvalue(x, 4)
  torch.return_types.kthvalue(values=tensor(4.), indices=tensor(3))

  >>> x=torch.arange(1.,7.).resize_(2,3)
  >>> x
  tensor([[ 1.,  2.,  3.],
          [ 4.,  5.,  6.]])
  >>> torch.kthvalue(x, 2, 0, True)
  torch.return_types.kthvalue(values=tensor([[4., 5., 6.]]), indices=tensor([[1, 1, 1]]))
interpolate
class torch.ao.nn.quantized.functional.interpolate(input, size=None, scale_factor=None, mode='nearest', align_corners=None)
Down/up samples the input to either the given "size" or the given
   "scale_factor"
See "torch.nn.functional.interpolate()" for implementation details.
The input dimensions are interpreted in the form: mini-batch x
   channels x [optional depth] x [optional height] x width.
Note:
 The input quantization parameters propagate to the output.

Note:
 Only 2D/3D input is supported for quantized inputs

Note:
 Only the following modes are supported for the quantized inputs:

 * *bilinear*

 * *nearest*

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

  * **scale_factor** (*float** or **Tuple**[**float**]*) --
multiplier for spatial size. Has to match input size if it is
        a tuple.
  * **mode** (*str*) -- algorithm used for upsampling: "'nearest'"
    | "'bilinear'"

  * **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 "'bilinear'".
    Default: "False"
torch.mul
torch.mul(input, other, *, out=None) -> Tensor
Multiplies "input" by "other".
  \text{out}_i = \text{input}_i \times \text{other}_i

Supports broadcasting to a common shape, type promotion, and
   integer, float, and complex inputs.
Parameters:
      * input (Tensor) -- the input tensor.
  * **other** (*Tensor** or **Number*) --

Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Examples:
  >>> a = torch.randn(3)
  >>> a
  tensor([ 0.2015, -0.4255,  2.6087])
  >>> torch.mul(a, 100)
  tensor([  20.1494,  -42.5491,  260.8663])

  >>> b = torch.randn(4, 1)
  >>> b
  tensor([[ 1.1207],
          [-0.3137],
          [ 0.0700],
          [ 0.8378]])
  >>> c = torch.randn(1, 4)
  >>> c
  tensor([[ 0.5146,  0.1216, -0.5244,  2.2382]])
  >>> torch.mul(b, c)
  tensor([[ 0.5767,  0.1363, -0.5877,  2.5083],
          [-0.1614, -0.0382,  0.1645, -0.7021],
torch.nn.functional.adaptive_avg_pool3d
torch.nn.functional.adaptive_avg_pool3d(input, output_size)
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 (None) -- the target output size (single
      integer or triple-integer tuple)
Return type:
      Tensor
torch.use_deterministic_algorithms
torch.use_deterministic_algorithms(mode, *, warn_only=False)
Sets whether PyTorch operations must use "deterministic"
   algorithms. That is, algorithms which, given the same input, and
   when run on the same software and hardware, always produce the same
   output. When enabled, operations will use deterministic algorithms
   when available, and if only nondeterministic algorithms are
   available they will throw a "RuntimeError" when called.
Note:
 This setting alone is not always enough to make an application
 reproducible. Refer to Reproducibility for more information.

Note:
 "torch.set_deterministic_debug_mode()" offers an alternative
 interface for this feature.

The following normally-nondeterministic operations will act
   deterministically when "mode=True":
  * "torch.nn.Conv1d" when called on CUDA tensor

  * "torch.nn.Conv2d" when called on CUDA tensor
"torch.nn.Conv3d" when called on CUDA tensor


"torch.nn.ConvTranspose1d" when called on CUDA tensor


"torch.nn.ConvTranspose2d" when called on CUDA tensor


"torch.nn.ConvTranspose3d" when called on CUDA tensor


"torch.bmm()" when called on sparse-dense CUDA tensors


"torch.Tensor.getitem()" when attempting to differentiate
    a CPU tensor and the index is a list of tensors


"torch.Tensor.index_put()" with "accumulate=False"


"torch.Tensor.index_put()" with "accumulate=True" when called
    on a CPU tensor


"torch.Tensor.put_()" with "accumulate=True" when called on a
    CPU tensor


"torch.Tensor.scatter_add_()" when called on a CUDA tensor


"torch.gather()" when called on a CUDA tensor that requires
    grad


"torch.index_add()" when called on CUDA tensor


"torch.index_select()" when attempting to differentiate a CUDA
    tensor
tensor
  * "torch.repeat_interleave()" when attempting to differentiate a
    CUDA tensor

  * "torch.Tensor.index_copy()" when called on a CPU or CUDA
    tensor

The following normally-nondeterministic operations will throw a
   "RuntimeError" when "mode=True":
  * "torch.nn.AvgPool3d" when attempting to differentiate a CUDA
    tensor

  * "torch.nn.AdaptiveAvgPool2d" when attempting to differentiate
    a CUDA tensor

  * "torch.nn.AdaptiveAvgPool3d" when attempting to differentiate
    a CUDA tensor

  * "torch.nn.MaxPool3d" when attempting to differentiate a CUDA
    tensor

  * "torch.nn.AdaptiveMaxPool2d" when attempting to differentiate
    a CUDA tensor

  * "torch.nn.FractionalMaxPool2d" when attempting to
    differentiate a CUDA tensor

  * "torch.nn.FractionalMaxPool3d" when attempting to
    differentiate a CUDA tensor

  * "torch.nn.MaxUnpool1d"

  * "torch.nn.MaxUnpool2d"
"torch.nn.MaxUnpool2d"


"torch.nn.MaxUnpool3d"


"torch.nn.functional.interpolate()" when attempting to
    differentiate a CUDA tensor and one of the following modes is
    used:


"linear"


"bilinear"


"bicubic"


"trilinear"




"torch.nn.ReflectionPad1d" when attempting to differentiate a
    CUDA tensor


"torch.nn.ReflectionPad2d" when attempting to differentiate a
    CUDA tensor


"torch.nn.ReflectionPad3d" when attempting to differentiate a
    CUDA tensor


"torch.nn.ReplicationPad1d" when attempting to differentiate a
    CUDA tensor


"torch.nn.ReplicationPad2d" when attempting to differentiate a
    CUDA tensor


"torch.nn.ReplicationPad3d" when attempting to differentiate a
    CUDA tensor


"torch.nn.NLLLoss" when called on a CUDA tensor


"torch.nn.CTCLoss" when attempting to differentiate a CUDA
    tensor
tensor
  * "torch.nn.EmbeddingBag" when attempting to differentiate a
    CUDA tensor when "mode='max'"

  * "torch.Tensor.put_()" when "accumulate=False"

  * "torch.Tensor.put_()" when "accumulate=True" and called on a
    CUDA tensor

  * "torch.histc()" when called on a CUDA tensor

  * "torch.bincount()" when called on a CUDA tensor

  * "torch.kthvalue()" with called on a CUDA tensor

  * "torch.median()" with indices output when called on a CUDA
    tensor

  * "torch.nn.functional.grid_sample()" when attempting to
    differentiate a CUDA tensor

  * "torch.cumsum()" when called on a CUDA tensor when dtype is
    floating point or complex

A handful of CUDA operations are nondeterministic if the CUDA
   version is 10.2 or greater, unless the environment variable
   "CUBLAS_WORKSPACE_CONFIG=:4096:8" or
   "CUBLAS_WORKSPACE_CONFIG=:16:8" is set. See the CUDA documentation
for more details: https://docs.nvidia.com/cuda/cublas/index.html#c
   ublasApi_reproducibility If one of these environment variable
   configurations is not set, a "RuntimeError" will be raised from
   these operations when called with CUDA tensors:
  * "torch.mm()"

  * "torch.mv()"

  * "torch.bmm()"

Note that deterministic operations tend to have worse performance
   than nondeterministic operations.
Note:
 This flag does not detect or prevent nondeterministic behavior
 caused by calling an inplace operation on a tensor with an
 internal memory overlap or by giving such a tensor as the "out"
 argument for an operation. In these cases, multiple writes of
 different data may target a single memory location, and the order
 of writes is not guaranteed.

Parameters:
      mode ("bool") -- If True, makes potentially nondeterministic
      operations switch to a deterministic algorithm or throw a
runtime error. If False, allows nondeterministic operations.
Keyword Arguments:
      warn_only ("bool", optional) -- If True, operations that do
      not have a deterministic implementation will throw a warning
      instead of an error. Default: "False"
Example:
  >>> torch.use_deterministic_algorithms(True)

  # Forward mode nondeterministic error
  >>> torch.randn(10, device='cuda').kthvalue(0)
  ...
  RuntimeError: kthvalue CUDA does not have a deterministic implementation...

  # Backward mode nondeterministic error
  >>> torch.nn.AvgPool3d(1)(torch.randn(3, 4, 5, 6, requires_grad=True).cuda()).sum().backward()
  ...
  RuntimeError: avg_pool3d_backward_cuda does not have a deterministic implementation...
torch.as_strided
torch.as_strided(input, size, stride, storage_offset=None) -> Tensor
Create a view of an existing torch.Tensor "input" with specified
   "size", "stride" and "storage_offset".
Warning:
 Prefer using other view functions, like "torch.Tensor.expand()",
 to setting a view's strides manually with *as_strided*, as this
 function's behavior depends on the implementation of a tensor's
 storage. The constructed view of the storage must only refer to
 elements within the storage or a runtime error will be thrown,
 and if the view is "overlapped" (with multiple indices referring
 to the same element in memory) its behavior is undefined.

Parameters:
      * input (Tensor) -- the input tensor.
  * **size** (*tuple** or **ints*) -- the shape of the output
    tensor

  * **stride** (*tuple** or **ints*) -- the stride of the output
    tensor

  * **storage_offset** (*int**, **optional*) -- the offset in the
underlying storage of the output tensor. If "None", the
        storage_offset of the output tensor will match the input
        tensor.
Example:
  >>> x = torch.randn(3, 3)
  >>> x
  tensor([[ 0.9039,  0.6291,  1.0795],
          [ 0.1586,  2.1939, -0.4900],
          [-0.1909, -0.7503,  1.9355]])
  >>> t = torch.as_strided(x, (2, 2), (1, 2))
  >>> t
  tensor([[0.9039, 1.0795],
          [0.6291, 0.1586]])
  >>> t = torch.as_strided(x, (2, 2), (1, 2), 1)
  tensor([[0.6291, 0.1586],
          [1.0795, 2.1939]])
torch.einsum
torch.einsum(equation, *operands) -> Tensor
Sums the product of the elements of the input "operands" along
   dimensions specified using a notation based on the Einstein
   summation convention.
Einsum allows computing many common multi-dimensional linear
   algebraic array operations by representing them in a short-hand
   format based on the Einstein summation convention, given by
   "equation". The details of this format are described below, but the
   general idea is to label every dimension of the input "operands"
   with some subscript and define which subscripts are part of the
   output. The output is then computed by summing the product of the
   elements of the "operands" along the dimensions whose subscripts
   are not part of the output. For example, matrix multiplication can
   be computed using einsum as torch.einsum("ij,jk->ik", A, B).
   Here, j is the summation subscript and i and k the output
   subscripts (see section below for more details on why).
Equation:
  The "equation" string specifies the subscripts (letters in
  *[a-zA-Z]*) for each dimension of the input "operands" in the
  same order as the dimensions, separating subscripts for each
  operand by a comma (','), e.g. *'ij,jk'* specify subscripts for
  two 2D operands. The dimensions labeled with the same subscript
  must be broadcastable, that is, their size must either match or
  be *1*. The exception is if a subscript is repeated for the same
  input operand, in which case the dimensions labeled with this
  subscript for this operand must match in size and the operand
  will be replaced by its diagonal along these dimensions. The
  subscripts that appear exactly once in the "equation" will be
  part of the output, sorted in increasing alphabetical order. The
  output is computed by multiplying the input "operands" element-
  wise, with their dimensions aligned based on the subscripts, and
then summing out the dimensions whose subscripts are not part of
      the output.
  Optionally, the output subscripts can be explicitly defined by
  adding an arrow ('->') at the end of the equation followed by
  the subscripts for the output. For instance, the following
  equation computes the transpose of a matrix multiplication:
  'ij,jk->ki'. The output subscripts must appear at least once for
  some input operand and at most once for the output.

  Ellipsis ('...') can be used in place of subscripts to broadcast
  the dimensions covered by the ellipsis. Each input operand may
  contain at most one ellipsis which will cover the dimensions not
  covered by subscripts, e.g. for an input operand with 5
  dimensions, the ellipsis in the equation *'ab...c'* cover the
  third and fourth dimensions. The ellipsis does not need to cover
  the same number of dimensions across the "operands" but the
'shape' of the ellipsis (the size of the dimensions covered by
      them) must broadcast together. If the output is not explicitly
      defined with the arrow ('->') notation, the ellipsis will come
      first in the output (left-most dimensions), before the subscript
      labels that appear exactly once for the input operands. e.g. the
      following equation implements batch matrix multiplication
      '...ij,...jk'.
  A few final notes: the equation may contain whitespaces between
  the different elements (subscripts, ellipsis, arrow and comma)
  but something like *'. . .'* is not valid. An empty string *''*
  is valid for scalar operands.

Note:
 "torch.einsum" handles ellipsis ('...') differently from NumPy in
 that it allows dimensions covered by the ellipsis to be summed
 over, that is, ellipsis are not required to be part of the
 output.

Note:
 This function uses opt_einsum (https://optimized-
einsum.readthedocs.io/en/stable/) to speed up computation or to
     consume less memory by optimizing contraction order. This
     optimization occurs when there are at least three inputs, since
     the order does not matter otherwise. Note that finding the
     optimal path is an NP-hard problem, thus, opt_einsum relies on
     different heuristics to achieve near-optimal results. If
     opt_einsum is not available, the default order is to contract
     from left to right.To bypass this default behavior, add the
     following line to disable the usage of opt_einsum and skip path
     calculation: torch.backends.opt_einsum.enabled = FalseTo
     specify which strategy you'd like for opt_einsum to compute the
     contraction path, add the following line:
     torch.backends.opt_einsum.strategy = 'auto'. The default
     strategy is 'auto', and we also support 'greedy' and 'optimal'.
     Disclaimer that the runtime of 'optimal' is factorial in the
number of inputs! See more details in the opt_einsum
     documentation (https://optimized-
     einsum.readthedocs.io/en/stable/path_finding.html).
Note:
 As of PyTorch 1.10 "torch.einsum()" also supports the sublist
 format (see examples below). In this format, subscripts for each
 operand are specified by sublists, list of integers in the range
 [0, 52). These sublists follow their operands, and an extra
 sublist can appear at the end of the input to specify the
 output's subscripts., e.g. *torch.einsum(op1, sublist1, op2,
 sublist2, ..., [subslist_out])*. Python's *Ellipsis* object may
 be provided in a sublist to enable broadcasting as described in
 the Equation section above.

Parameters:
      * equation (str) -- The subscripts for the Einstein
        summation.
  * **operands** (*List**[**Tensor**]*) -- The tensors to compute
    the Einstein summation of.

Return type:
      Tensor
Examples:
  >>> # trace
Tensor
Examples:
  >>> # trace
  >>> torch.einsum('ii', torch.randn(4, 4))
  tensor(-1.2104)

  >>> # diagonal
  >>> torch.einsum('ii->i', torch.randn(4, 4))
  tensor([-0.1034,  0.7952, -0.2433,  0.4545])

  >>> # outer product
  >>> x = torch.randn(5)
  >>> y = torch.randn(4)
  >>> torch.einsum('i,j->ij', x, y)
  tensor([[ 0.1156, -0.2897, -0.3918,  0.4963],
          [-0.3744,  0.9381,  1.2685, -1.6070],
          [ 0.7208, -1.8058, -2.4419,  3.0936],
          [ 0.1713, -0.4291, -0.5802,  0.7350],
          [ 0.5704, -1.4290, -1.9323,  2.4480]])

  >>> # batch matrix multiplication
  >>> As = torch.randn(3, 2, 5)
  >>> Bs = torch.randn(3, 5, 4)
  >>> torch.einsum('bij,bjk->bik', As, Bs)
  tensor([[[-1.0564, -1.5904,  3.2023,  3.1271],
          [-1.6706, -0.8097, -0.8025, -2.1183]],

          [[ 4.2239,  0.3107, -0.5756, -0.2354],
          [-1.4558, -0.3460,  1.5087, -0.8530]],
[[ 2.8153,  1.8787, -4.3839, -1.2112],
              [ 0.3728, -2.1131,  0.0921,  0.8305]]])
  >>> # with sublist format and ellipsis
  >>> torch.einsum(As, [..., 0, 1], Bs, [..., 1, 2], [..., 0, 2])
  tensor([[[-1.0564, -1.5904,  3.2023,  3.1271],
          [-1.6706, -0.8097, -0.8025, -2.1183]],

          [[ 4.2239,  0.3107, -0.5756, -0.2354],
          [-1.4558, -0.3460,  1.5087, -0.8530]],

          [[ 2.8153,  1.8787, -4.3839, -1.2112],
          [ 0.3728, -2.1131,  0.0921,  0.8305]]])

  >>> # batch permute
  >>> A = torch.randn(2, 3, 4, 5)
  >>> torch.einsum('...ij->...ji', A).shape
  torch.Size([2, 3, 5, 4])

  >>> # equivalent to torch.nn.functional.bilinear
  >>> A = torch.randn(3, 5, 4)
  >>> l = torch.randn(2, 5)
  >>> r = torch.randn(2, 4)
  >>> torch.einsum('bn,anm,bm->ba', l, A, r)
  tensor([[-0.3430, -5.2405,  0.4494],
          [ 0.3311,  5.5201, -3.0356]])
torch.linalg.ldl_factor_ex
torch.linalg.ldl_factor_ex(A, *, hermitian=False, check_errors=False, out=None)
This is a version of "ldl_factor()" that does not perform error
   checks unless "check_errors"= True. It also returns the "info"
   tensor returned by LAPACK's sytrf. "info" stores integer error
   codes from the backend library. A positive integer indicates the
   diagonal element of D that is zero. Division by 0 will occur if the
   result is used for solving a system of linear equations. "info"
   filled with zeros indicates that the factorization was successful.
   If "check_errors=True" and "info" contains positive integers, then
   a RuntimeError is thrown.
Note:
 When the inputs are on a CUDA device, this function synchronizes
 only when "check_errors"*= True*.

Warning:
 This function is "experimental" and it may change in a future
 PyTorch release.

Parameters:
      A (Tensor) -- tensor of shape (*, n, n) where * is zero or
more batch dimensions consisting of symmetric or Hermitian
      matrices. (*, n, n) where *** is one or more batch dimensions.
Keyword Arguments:
      * hermitian (bool, optional) -- whether to consider
        the input to be Hermitian or symmetric. For real-valued
        matrices, this switch has no effect. Default: False.
  * **check_errors** (*bool**, **optional*) -- controls whether to
    check the content of "info" and raise an error if it is non-
    zero. Default: *False*.

  * **out** (*tuple**, **optional*) -- tuple of three tensors to
    write the output to. Ignored if *None*. Default: *None*.

Returns:
      A named tuple (LD, pivots, info).
Examples:
  >>> A = torch.randn(3, 3)
  >>> A = A @ A.mT # make symmetric
  >>> A
  tensor([[7.2079, 4.2414, 1.9428],
          [4.2414, 3.4554, 0.3264],
          [1.9428, 0.3264, 1.3823]])
  >>> LD, pivots, info = torch.linalg.ldl_factor_ex(A)
  >>> LD
LD
      tensor([[ 7.2079,  0.0000,  0.0000],
              [ 0.5884,  0.9595,  0.0000],
              [ 0.2695, -0.8513,  0.1633]])
      >>> pivots
      tensor([1, 2, 3], dtype=torch.int32)
      >>> info
      tensor(0, dtype=torch.int32)
torch.nn.utils.prune.random_unstructured
torch.nn.utils.prune.random_unstructured(module, name, amount)
Prunes tensor corresponding to parameter called "name" in "module"
   by removing the specified "amount" of (currently unpruned) units
   selected at random. Modifies module in place (and also return the
   modified module) by:


adding a named buffer called "name+'_mask'" corresponding to the
      binary mask applied to the parameter "name" by the pruning
      method.


replacing the parameter "name" by its pruned version, while the
      original (unpruned) parameter is stored in a new parameter named
      "name+'_orig'".


Parameters:
      * module (nn.Module) -- module containing the tensor to
        prune
  * **name** (*str*) -- parameter name within "module" on which
    pruning will act.

  * **amount** (*int** or **float*) -- quantity of parameters to
prune. If "float", should be between 0.0 and 1.0 and represent
        the fraction of parameters to prune. If "int", it represents
        the absolute number of parameters to prune.
Returns:
      modified (i.e. pruned) version of the input module
Return type:
      module (nn.Module)
-[ Examples ]-



m = prune.random_unstructured(nn.Linear(2, 3), 'weight', amount=1)
torch.sum(m.weight_mask == 0)
   tensor(1)
clamp
class torch.ao.nn.quantized.functional.clamp(input, min_, max_)
float(input, min_, max_) -> Tensor
Applies the clamp function element-wise. See "clamp" for more
   details.
Parameters:
      * input (Tensor) -- quantized input
  * **min** -- minimum value for clamping

  * **max** -- maximum value for clamping

Return type:
      Tensor
torch.Tensor.scatter_
Tensor.scatter_(dim, index, src, reduce=None) -> Tensor
Writes all values from the tensor "src" into "self" at the indices
   specified in the "index" tensor. For each value in "src", its
   output index is specified by its index in "src" for "dimension !=
   dim" and by the corresponding value in "index" for "dimension =
   dim".
For a 3-D tensor, "self" is updated as:
  self[index[i][j][k]][j][k] = src[i][j][k]  # if dim == 0
  self[i][index[i][j][k]][k] = src[i][j][k]  # if dim == 1
  self[i][j][index[i][j][k]] = src[i][j][k]  # if dim == 2

This is the reverse operation of the manner described in
   "gather()".
"self", "index" and "src" (if it is a Tensor) should all have the
   same number of dimensions. It is also required that "index.size(d)
   <= src.size(d)" for all dimensions "d", and that "index.size(d) <=
   self.size(d)" for all dimensions "d != dim". Note that "index" and
   "src" do not broadcast.
"src" do not broadcast.
Moreover, as for "gather()", the values of "index" must be between
   "0" and "self.size(dim) - 1" inclusive.
Warning:
 When indices are not unique, the behavior is non-deterministic
 (one of the values from "src" will be picked arbitrarily) and the
 gradient will be incorrect (it will be propagated to all
 locations in the source that correspond to the same index)!

Note:
 The backward pass is implemented only for "src.shape ==
 index.shape".

Additionally accepts an optional "reduce" argument that allows
   specification of an optional reduction operation, which is applied
   to all values in the tensor "src" into "self" at the indices
   specified in the "index". For each value in "src", the reduction
   operation is applied to an index in "self" which is specified by
   its index in "src" for "dimension != dim" and by the corresponding
   value in "index" for "dimension = dim".
Given a 3-D tensor and reduction using the multiplication