shrinath-suresh/blogs-docs-splitted huggingface dataset:
torch.lu
torch.lu(args, *kwargs)
Computes the LU factorization of a matrix or batches of matrices
   "A". Returns a tuple containing the LU factorization and pivots of
   "A".  Pivoting is done if "pivot" is set to "True".
Warning:
 "torch.lu()" is deprecated in favor of "torch.linalg.lu_factor()"
 and "torch.linalg.lu_factor_ex()". "torch.lu()" will be removed
 in a future PyTorch release. "LU, pivots, info = torch.lu(A,
 compute_pivots)" should be replaced with

    LU, pivots = torch.linalg.lu_factor(A, compute_pivots)

 "LU, pivots, info = torch.lu(A, compute_pivots, get_infos=True)"
 should be replaced with

    LU, pivots, info = torch.linalg.lu_factor_ex(A, compute_pivots)

Note:
 * The returned permutation matrix for every matrix in the batch
   is represented by a 1-indexed vector of size "min(A.shape[-2],
   A.shape[-1])". "pivots[i] == j" represents that in the "i"-th
step of the algorithm, the "i"-th row was permuted with the
       "j-1"-th row.
 * LU factorization with "pivot" = "False" is not available for
   CPU, and attempting to do so will throw an error. However, LU
   factorization with "pivot" = "False" is available for CUDA.

 * This function does not check if the factorization was
   successful or not if "get_infos" is "True" since the status of
   the factorization is present in the third element of the return
   tuple.

 * In the case of batches of square matrices with size less or
   equal to 32 on a CUDA device, the LU factorization is repeated
   for singular matrices due to the bug in the MAGMA library (see
   magma issue 13).

 * "L", "U", and "P" can be derived using "torch.lu_unpack()".

Warning:
 The gradients of this function will only be finite when "A" is
 full rank. This is because the LU decomposition is just
 differentiable at full rank matrices. Furthermore, if "A" is
close to not being full rank, the gradient will be numerically
     unstable as it depends on the computation of L^{-1} and U^{-1}.
Parameters:
      * A (Tensor) -- the tensor to factor of size (*, m, n)
  * **pivot** (*bool**, **optional*) -- controls whether pivoting
    is done. Default: "True"

  * **get_infos** (*bool**, **optional*) -- if set to "True",
    returns an info IntTensor. Default: "False"

  * **out** (*tuple**, **optional*) -- optional output tuple. If
    "get_infos" is "True", then the elements in the tuple are
    Tensor, IntTensor, and IntTensor. If "get_infos" is "False",
    then the elements in the tuple are Tensor, IntTensor. Default:
    "None"

Returns:
      A tuple of tensors containing
     * **factorization** (*Tensor*): the factorization of size (*,
       m, n)

     * **pivots** (*IntTensor*): the pivots of size (*,
       \text{min}(m, n)). "pivots" stores all the intermediate
transpositions of rows. The final permutation "perm" could
           be reconstructed by applying "swap(perm[i], perm[pivots[i]
           - 1])" for "i = 0, ..., pivots.size(-1) - 1", where "perm"
           is initially the identity permutation of m elements
           (essentially this is what "torch.lu_unpack()" is doing).
     * **infos** (*IntTensor*, *optional*): if "get_infos" is
       "True", this is a tensor of size (*) where non-zero values
       indicate whether factorization for the matrix or each
       minibatch has succeeded or failed

Return type:
      (Tensor, IntTensor, IntTensor (optional))
Example:
  >>> A = torch.randn(2, 3, 3)
  >>> A_LU, pivots = torch.lu(A)
  >>> A_LU
  tensor([[[ 1.3506,  2.5558, -0.0816],
           [ 0.1684,  1.1551,  0.1940],
           [ 0.1193,  0.6189, -0.5497]],

          [[ 0.4526,  1.2526, -0.3285],
           [-0.7988,  0.7175, -0.9701],
           [ 0.2634, -0.9255, -0.3459]]])
[ 0.2634, -0.9255, -0.3459]]])
      >>> pivots
      tensor([[ 3,  3,  3],
              [ 3,  3,  3]], dtype=torch.int32)
      >>> A_LU, pivots, info = torch.lu(A, get_infos=True)
      >>> if info.nonzero().size(0) == 0:
      ...     print('LU factorization succeeded for all samples!')
      LU factorization succeeded for all samples!
torch.trunc
torch.trunc(input, *, out=None) -> Tensor
Returns a new tensor with the truncated integer values of the
   elements of "input".
For integer inputs, follows the array-api convention of returning a
   copy of the input tensor.
Parameters:
      input (Tensor) -- the input tensor.
Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> a = torch.randn(4)
  >>> a
  tensor([ 3.4742,  0.5466, -0.8008, -0.9079])
  >>> torch.trunc(a)
  tensor([ 3.,  0., -0., -0.])
torch.linalg.cholesky
torch.linalg.cholesky(A, *, upper=False, out=None) -> Tensor
Computes the Cholesky decomposition of a complex Hermitian or real
   symmetric positive-definite matrix.
Letting \mathbb{K} be \mathbb{R} or \mathbb{C}, the Cholesky
   decomposition of a complex Hermitian or real symmetric positive-
   definite matrix A \in \mathbb{K}^{n \times n} is defined as
  A = LL^{\text{H}}\mathrlap{\qquad L \in \mathbb{K}^{n \times n}}

where L is a lower triangular matrix with real positive diagonal
   (even in the complex case) and L^{\text{H}} is the conjugate
   transpose when L is complex, and the transpose when L is real-
   valued.
Supports input of float, double, cfloat and cdouble dtypes. Also
   supports batches of matrices, and if "A" is a batch of matrices
   then the output has the same batch dimensions.
Note:
 When inputs are on a CUDA device, this function synchronizes that
 device with the CPU.

See also:
device with the CPU.
See also:
 "torch.linalg.cholesky_ex()" for a version of this operation that
 skips the (slow) error checking by default and instead returns
 the debug information. This makes it a faster way to check if a
 matrix is positive-definite.

 "torch.linalg.eigh()" for a different decomposition of a
 Hermitian matrix. The eigenvalue decomposition gives more
 information about the matrix but it slower to compute than the
 Cholesky decomposition.

Parameters:
      A (Tensor) -- tensor of shape (, n, n)* where *** is
      zero or more batch dimensions consisting of symmetric or
      Hermitian positive-definite matrices.
Keyword Arguments:
      * upper (bool, optional) -- whether to return an upper
        triangular matrix. The tensor returned with upper=True is the
        conjugate transpose of the tensor returned with upper=False.
  * **out** (*Tensor**, **optional*) -- output tensor. Ignored if
None. Default: None.
Raises:
      RuntimeError -- if the "A" matrix or any matrix in a batched
      "A" is not Hermitian     (resp. symmetric) positive-definite. If
      "A" is a batch of matrices,     the error message will include
      the batch index of the first matrix that fails     to meet this
      condition.
Examples:
  >>> A = torch.randn(2, 2, dtype=torch.complex128)
  >>> A = A @ A.T.conj() + torch.eye(2) # creates a Hermitian positive-definite matrix
  >>> A
  tensor([[2.5266+0.0000j, 1.9586-2.0626j],
          [1.9586+2.0626j, 9.4160+0.0000j]], dtype=torch.complex128)
  >>> L = torch.linalg.cholesky(A)
  >>> L
  tensor([[1.5895+0.0000j, 0.0000+0.0000j],
          [1.2322+1.2976j, 2.4928+0.0000j]], dtype=torch.complex128)
  >>> torch.dist(L @ L.T.conj(), A)
  tensor(4.4692e-16, dtype=torch.float64)

  >>> A = torch.randn(3, 2, 2, dtype=torch.float64)
torch.nn.functional.conv_transpose3d
torch.nn.functional.conv_transpose3d(input, weight, bias=None, stride=1, padding=0, output_padding=0, groups=1, dilation=1) -> Tensor
Applies a 3D transposed convolution operator over an input image
   composed of several input planes, sometimes also called
   "deconvolution"
This operator supports TensorFloat32.
See "ConvTranspose3d" for details and output shape.
Note:
 In some circumstances when given tensors on a CUDA device and
 using CuDNN, this operator may select a nondeterministic
 algorithm to increase performance. If this is undesirable, you
 can try to make the operation deterministic (potentially at a
 performance cost) by setting "torch.backends.cudnn.deterministic
 = True". See Reproducibility for more information.

Parameters:
      * input -- input tensor of shape (\text{minibatch} ,
        \text{in_channels} , iT , iH , iW)
\text{in_channels} , iT , iH , iW)
  * **weight** -- filters of shape (\text{in\_channels} ,
    \frac{\text{out\_channels}}{\text{groups}} , kT , kH , kW)

  * **bias** -- optional bias of shape (\text{out\_channels}).
    Default: None

  * **stride** -- the stride of the convolving kernel. Can be a
    single number or a tuple "(sT, sH, sW)". Default: 1

  * **padding** -- "dilation * (kernel_size - 1) - padding" zero-
    padding will be added to both sides of each dimension in the
    input. Can be a single number or a tuple "(padT, padH, padW)".
    Default: 0

  * **output_padding** -- additional size added to one side of
    each dimension in the output shape. Can be a single number or
    a tuple "(out_padT, out_padH, out_padW)". Default: 0

  * **groups** -- split input into groups, \text{in\_channels}
    should be divisible by the number of groups. Default: 1

  * **dilation** -- the spacing between kernel elements. Can be a
torch.cuda.memory_usage
torch.cuda.memory_usage(device=None)
Returns the percent of time over the past sample period during
   which global (device) memory was being read or written. as given by
   nvidia-smi.
Parameters:
      device (torch.device or int, optional) -- selected
      device. Returns statistic for the current device, given by
      "current_device()", if "device" is "None" (default).
Return type:
      int
Warning: Each sample period may be between 1 second and 1/6 second,
   depending on the product being queried.
ConvTranspose1d
class torch.ao.nn.quantized.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=1, padding=0, output_padding=0, groups=1, bias=True, dilation=1, padding_mode='zeros', device=None, dtype=None)
Applies a 1D transposed convolution operator over an input image
   composed of several input planes. For details on input arguments,
   parameters, and implementation see "ConvTranspose1d".
Note:
 Currently only the QNNPACK engine is implemented. Please, set the
 *torch.backends.quantized.engine = 'qnnpack'*

For special notes, please, see "Conv1d"
Variables:
      * weight (Tensor) -- packed tensor derived from the
        learnable weight parameter.
  * **scale** (*Tensor*) -- scalar for the output scale

  * **zero_point** (*Tensor*) -- scalar for the output zero point

See "ConvTranspose2d" for other attributes.
Examples:
  >>> torch.backends.quantized.engine = 'qnnpack'
  >>> from torch.nn import quantized as nnq
from torch.nn import quantized as nnq
      >>> # With square kernels and equal stride
      >>> m = nnq.ConvTranspose1d(16, 33, 3, stride=2)
      >>> # non-square kernels and unequal stride and with padding
      >>> m = nnq.ConvTranspose1d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2))
      >>> input = torch.randn(20, 16, 50)
      >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8)
      >>> output = m(q_input)
      >>> # exact output size can be also specified as an argument
      >>> input = torch.randn(1, 16, 12)
      >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8)
      >>> downsample = nnq.Conv1d(16, 16, 3, stride=2, padding=1)
      >>> upsample = nnq.ConvTranspose1d(16, 16, 3, stride=2, padding=1)
      >>> h = downsample(q_input)
      >>> h.size()
      torch.Size([1, 16, 6])
      >>> output = upsample(h, output_size=input.size())
      >>> output.size()
      torch.Size([1, 16, 12])
torch.linalg.solve_triangular
torch.linalg.solve_triangular(A, B, *, upper, left=True, unitriangular=False, out=None) -> Tensor
Computes the solution of a triangular system of linear equations
   with a unique solution.
Letting \mathbb{K} be \mathbb{R} or \mathbb{C}, this function
   computes the solution X \in \mathbb{K}^{n \times k} of the linear
   system associated to the triangular matrix A \in \mathbb{K}^{n
   \times n} without zeros on the diagonal (that is, it is invertible)
   and the rectangular matrix , B \in \mathbb{K}^{n \times k}, which
   is defined as
  AX = B

The argument "upper" signals whether A is upper or lower
   triangular.
If "left"= False, this function returns the matrix X \in
   \mathbb{K}^{n \times k} that solves the system
  XA = B\mathrlap{\qquad A \in \mathbb{K}^{k \times k}, B \in
  \mathbb{K}^{n \times k}.}

If "upper"= True (resp. False) just the upper (resp. lower)
triangular half of "A" will be accessed. The elements below the
   main diagonal will be considered to be zero and will not be
   accessed.
If "unitriangular"= True, the diagonal of "A" is assumed to be
   ones and will not be accessed.
The result may contain NaN s if the diagonal of "A" contains
   zeros or elements that are very close to zero and "unitriangular"=
   False (default) or if the input matrix has very small eigenvalues.
Supports inputs of float, double, cfloat and cdouble dtypes. Also
   supports batches of matrices, and if the inputs are batches of
   matrices then the output has the same batch dimensions.
See also:
 "torch.linalg.solve()" computes the solution of a general square
 system of linear equations with a unique solution.

Parameters:
      * A (Tensor) -- tensor of shape (, n, n) (or (, k,
        k) if "left"= True) where *** is zero or more batch
        dimensions.
dimensions.
  * **B** (*Tensor*) -- right-hand side tensor of shape *(*, n,
    k)*.

Keyword Arguments:
      * upper (bool) -- whether "A" is an upper or lower
        triangular matrix.
  * **left** (*bool**, **optional*) -- whether to solve the system
    AX=B or XA = B. Default: *True*.

  * **unitriangular** (*bool**, **optional*) -- if *True*, the
    diagonal elements of "A" are assumed to be all equal to *1*.
    Default: *False*.

  * **out** (*Tensor**, **optional*) -- output tensor. *B* may be
    passed as *out* and the result is computed in-place on *B*.
    Ignored if *None*. Default: *None*.

Examples:
  >>> A = torch.randn(3, 3).triu_()
  >>> b = torch.randn(3, 4)
  >>> X = torch.linalg.solve_triangular(A, B, upper=True)
  >>> torch.allclose(A @ X, B)
  True

  >>> A = torch.randn(2, 3, 3).tril_()
  >>> B = torch.randn(2, 3, 4)
  >>> X = torch.linalg.solve_triangular(A, B, upper=False)
torch.cov
torch.cov(input, *, correction=1, fweights=None, aweights=None) -> Tensor
Estimates the covariance matrix of the variables given by the
   "input" matrix, where rows are the variables and columns are the
   observations.
A covariance matrix is a square matrix giving the covariance of
   each pair of variables. The diagonal contains the variance of each
   variable (covariance of a variable with itself). By definition, if
   "input" represents a single variable (Scalar or 1D) then its
   variance is returned.
The unbiased sample covariance of the variables x and y is given
   by:
  \text{cov}_w(x,y) = \frac{\sum^{N}_{i = 1}(x_{i} -
  \bar{x})(y_{i} - \bar{y})}{N~-~1}

where \bar{x} and \bar{y} are the simple means of the x and y
   respectively.
If "fweights" and/or "aweights" are provided, the unbiased weighted
   covariance is calculated, which is given by:
  \text{cov}_w(x,y) = \frac{\sum^{N}_{i = 1}w_i(x_{i} -
\mu_x^)(y_{i} - \mu_y^)}{\sum^{N}_{i = 1}w_i~-~1}
where w denotes "fweights" or "aweights" based on whichever is
   provided, or w = fweights \times aweights if both are provided, and
   \mu_x^* = \frac{\sum^{N}{i = 1}w_ix }{\sum^{N}_{i = 1}w_i} is
   the weighted mean of the variable.
Parameters:
      input (Tensor) -- A 2D matrix containing multiple
      variables and observations, or a Scalar or 1D vector
      representing a single variable.
Keyword Arguments:
      * correction (int, optional) -- difference between the
        sample size and sample degrees of freedom. Defaults to
        Bessel's correction, "correction = 1" which returns the
        unbiased estimate, even if both "fweights" and "aweights" are
        specified. "correction = 0" will return the simple average.
        Defaults to "1".
  * **fweights** (*tensor**, **optional*) -- A Scalar or 1D tensor
    of observation vector frequencies representing the number of
times each observation should be repeated. Its numel must
        equal the number of columns of "input". Must have integral
        dtype. Ignored if "None". Defaults to `None.
  * **aweights** (*tensor**, **optional*) -- A Scalar or 1D array
    of observation vector weights. These relative weights are
    typically large for observations considered âimportantâ and
    smaller for observations considered less âimportantâ. Its
    numel must equal the number of columns of "input". Must have
    floating point dtype. Ignored if "None". *Defaults to
    ``None`*.

Returns:
      (Tensor) The covariance matrix of the variables.
See also: "torch.corrcoef()" normalized covariance matrix.
Example::
      >>> x = torch.tensor([[0, 2], [1, 1], [2, 0]]).T
      >>> x
      tensor([[0, 1, 2],
              [2, 1, 0]])
      >>> torch.cov(x)
      tensor([[ 1., -1.],
              [-1.,  1.]])
      >>> torch.cov(x, correction=0)
torch.cov(x, correction=0)
      tensor([[ 0.6667, -0.6667],
              [-0.6667,  0.6667]])
      >>> fw = torch.randint(1, 10, (3,))
      >>> fw
      tensor([1, 6, 9])
      >>> aw = torch.rand(3)
      >>> aw
      tensor([0.4282, 0.0255, 0.4144])
      >>> torch.cov(x, fweights=fw, aweights=aw)
      tensor([[ 0.4169, -0.4169],
              [-0.4169,  0.4169]])
torch.asarray
torch.asarray(obj, *, dtype=None, device=None, copy=None, requires_grad=False) -> Tensor
Converts "obj" to a tensor.
"obj" can be one of:


a tensor


a NumPy array


a DLPack capsule


an object that implements Python's buffer protocol


a scalar


a sequence of scalars


When "obj" is a tensor, NumPy array, or DLPack capsule the returned
   tensor will, by default, not require a gradient, have the same
   datatype as "obj", be on the same device, and share memory with it.
   These properties can be controlled with the "dtype", "device",
   "copy", and "requires_grad" keyword arguments. If the returned
   tensor is of a different datatype, on a different device, or a copy
   is requested then it will not share its memory with "obj". If
   "requires_grad" is "True" then the returned tensor will require a
   gradient, and if "obj" is also a tensor with an autograd history
   then the returned tensor will have the same history.
When "obj" is not a tensor, NumPy Array, or DLPack capsule but
   implements Python's buffer protocol then the buffer is interpreted
   as an array of bytes grouped according to the size of the datatype
   passed to the "dtype" keyword argument. (If no datatype is passed
   then the default floating point datatype is used, instead.) The
   returned tensor will have the specified datatype (or default
   floating point datatype if none is specified) and, by default, be
   on the CPU device and share memory with the buffer.
When "obj" is none of the above but a scalar or sequence of scalars
   then the returned tensor will, by default, infer its datatype from
   the scalar values, be on the CPU device, and not share its memory.
See also:
 "torch.tensor()" creates a tensor that always copies the data
 from the input object. "torch.from_numpy()" creates a tensor that
 always shares memory from NumPy arrays. "torch.frombuffer()"
creates a tensor that always shares memory from objects that
     implement the buffer protocol. "torch.from_dlpack()" creates a
     tensor that always shares memory from DLPack capsules.
Parameters:
      obj (object) -- a tensor, NumPy array, DLPack Capsule,
      object that implements Python's buffer protocol, scalar, or
      sequence of scalars.
Keyword Arguments:
      * dtype ("torch.dtype", optional) -- the datatype of the
        returned tensor. Default: "None", which causes the datatype of
        the returned tensor to be inferred from "obj".
  * **copy** (*bool**, **optional*) -- controls whether the
    returned tensor shares memory with "obj". Default: "None",
    which causes the returned tensor to share memory with "obj"
    whenever possible. If "True" then the returned tensor does not
    share its memory. If "False" then the returned tensor shares
    its memory with "obj" and an error is thrown if it cannot.
device ("torch.device", optional) -- the device of the
        returned tensor. Default: "None", which causes the device of
        "obj" to be used.

requires_grad (bool, optional) -- whether the
    returned tensor requires grad. Default: "False", which causes
    the returned tensor not to require a gradient. If "True", then
    the returned tensor will require a gradient, and if "obj" is
    also a tensor with an autograd history then the returned
    tensor will have the same history.



Example:
  >>> a = torch.tensor([1, 2, 3])
  >>> # Shares memory with tensor 'a'
  >>> b = torch.asarray(a)
  >>> a.data_ptr() == b.data_ptr()
  True
  >>> # Forces memory copy
  >>> c = torch.asarray(a, copy=True)
  >>> a.data_ptr() == c.data_ptr()
  False

  >>> a = torch.tensor([1, 2, 3], requires_grad=True).float()
  >>> b = a + 2
  >>> b
  tensor([1., 2., 3.], grad_fn=<AddBackward0>)
tensor([1., 2., 3.], grad_fn=)
      >>> # Shares memory with tensor 'b', with no grad
      >>> c = torch.asarray(b)
      >>> c
      tensor([1., 2., 3.])
      >>> # Shares memory with tensor 'b', retaining autograd history
      >>> d = torch.asarray(b, requires_grad=True)
      >>> d
      tensor([1., 2., 3.], grad_fn=)
  >>> array = numpy.array([1, 2, 3])
  >>> # Shares memory with array 'array'
  >>> t1 = torch.asarray(array)
  >>> array.__array_interface__['data'][0] == t1.data_ptr()
  True
  >>> # Copies memory due to dtype mismatch
  >>> t2 = torch.asarray(array, dtype=torch.float32)
  >>> array.__array_interface__['data'][0] == t1.data_ptr()
  False
torch.argwhere
torch.argwhere(input) -> Tensor
Returns a tensor containing the indices of all non-zero elements of
   "input".  Each row in the result contains the indices of a non-zero
   element in "input". The result is sorted lexicographically, with
   the last index changing the fastest (C-style).
If "input" has n dimensions, then the resulting indices tensor
   "out" is of size (z \times n), where z is the total number of non-
   zero elements in the "input" tensor.
Note:
 This function is similar to NumPy's *argwhere*.When "input" is on
 CUDA, this function causes host-device synchronization.

Parameters:
      {input} --
Example:
  >>> t = torch.tensor([1, 0, 1])
  >>> torch.argwhere(t)
  tensor([[0],
          [2]])
  >>> t = torch.tensor([[1, 0, 1], [0, 1, 1]])
  >>> torch.argwhere(t)
  tensor([[0, 0],
          [0, 2],
          [1, 1],
          [1, 2]])
NoopObserver
class torch.quantization.observer.NoopObserver(dtype=torch.float16, custom_op_name='')
Observer that doesn't do anything and just passes its configuration
   to the quantized module's ".from_float()".
Primarily used for quantization to float16 which doesn't require
   determining ranges.
Parameters:
      * dtype -- Quantized data type
  * **custom_op_name** -- (temporary) specify this observer for an
    operator that doesn't require any observation (Can be used in
    Graph Mode Passes for special case ops).
torch.nn.functional.mish
torch.nn.functional.mish(input, inplace=False)
Applies the Mish function, element-wise. Mish: A Self Regularized
   Non-Monotonic Neural Activation Function.
  \text{Mish}(x) = x * \text{Tanh}(\text{Softplus}(x))

Note:
 See Mish: A Self Regularized Non-Monotonic Neural Activation
 Function

See "Mish" for more details.
Return type:
      Tensor