shrinath-suresh/blogs-docs-splitted huggingface dataset:
the equation above.
  * **dtype** ("torch.dtype", optional) -- the desired data type
    of returned tensor. Default: if "None", uses a global default
    (see "torch.set_default_tensor_type()").

  * **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".

Return type:
      Tensor
Examples:
  >>> # Generates a symmetric Hamming window.
  >>> torch.signal.windows.hamming(10)
torch.signal.windows.hamming(10)
      tensor([0.0800, 0.1876, 0.4601, 0.7700, 0.9723, 0.9723, 0.7700, 0.4601, 0.1876, 0.0800])



  >>> # Generates a periodic Hamming window.
  >>> torch.signal.windows.hamming(10, sym=False)
  tensor([0.0800, 0.1679, 0.3979, 0.6821, 0.9121, 1.0000, 0.9121, 0.6821, 0.3979, 0.1679])
torch.fft.fftn
torch.fft.fftn(input, s=None, dim=None, norm=None, *, out=None) -> Tensor
Computes the N dimensional discrete Fourier transform of "input".
Note:
 The Fourier domain representation of any real signal satisfies
 the Hermitian property: "X[i_1, ..., i_n] = conj(X[-i_1, ...,
 -i_n])". This function always returns all positive and negative
 frequency terms even though, for real inputs, half of these
 values are redundant. "rfftn()" returns the more compact one-
 sided representation where only the positive frequencies of the
 last dimension are returned.

Note:
 Supports torch.half and torch.chalf on CUDA with GPU Architecture
 SM53 or greater. However it only supports powers of 2 signal
 length in every transformed dimensions.

Parameters:
      * input (Tensor) -- the input tensor
  * **s** (*Tuple**[**int**]**, **optional*) -- Signal size in the
transformed dimensions. If given, each dimension "dim[i]" will
        either be zero-padded or trimmed to the length "s[i]" before
        computing the FFT. If a length "-1" is specified, no padding
        is done in that dimension. Default: "s = [input.size(d) for d
        in dim]"
  * **dim** (*Tuple**[**int**]**, **optional*) -- Dimensions to be
    transformed. Default: all dimensions, or the last "len(s)"
    dimensions if "s" is given.

  * **norm** (*str**, **optional*) --

    Normalization mode. For the forward transform ("fftn()"),
    these correspond to:

    * ""forward"" - normalize by "1/n"

    * ""backward"" - no normalization

    * ""ortho"" - normalize by "1/sqrt(n)" (making the FFT
      orthonormal)

    Where "n = prod(s)" is the logical FFT size. Calling the
    backward transform ("ifftn()") with the same normalization
    mode will apply an overall normalization of "1/n" between the
two transforms. This is required to make "ifftn()" the exact
        inverse.
    Default is ""backward"" (no normalization).

Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
-[ Example ]-



x = torch.rand(10, 10, dtype=torch.complex64)
fftn = torch.fft.fftn(x)



The discrete Fourier transform is separable, so "fftn()" here is
   equivalent to two one-dimensional "fft()" calls:



two_ffts = torch.fft.fft(torch.fft.fft(x, dim=0), dim=1)
torch.testing.assert_close(fftn, two_ffts, check_stride=False)
torch.atanh
torch.atanh(input, *, out=None) -> Tensor
Returns a new tensor with the inverse hyperbolic tangent of the
   elements of "input".
Note:
 The domain of the inverse hyperbolic tangent is *(-1, 1)* and
 values outside this range will be mapped to "NaN", except for the
 values *1* and *-1* for which the output is mapped to *+/-INF*
 respectively.

  \text{out}_{i} = \tanh^{-1}(\text{input}_{i})

Parameters:
      input (Tensor) -- the input tensor.
Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> a = torch.randn(4).uniform_(-1, 1)
  >>> a
  tensor([ -0.9385, 0.2968, -0.8591, -0.1871 ])
  >>> torch.atanh(a)
  tensor([ -1.7253, 0.3060, -1.2899, -0.1893 ])
MinMaxObserver
class torch.quantization.observer.MinMaxObserver(dtype=torch.quint8, qscheme=torch.per_tensor_affine, reduce_range=False, quant_min=None, quant_max=None, factory_kwargs=None, eps=1.1920928955078125e-07)
Observer module for computing the quantization parameters based on
   the running min and max values.
This observer uses the tensor min/max statistics to compute the
   quantization parameters. The module records the running minimum and
   maximum of incoming tensors, and uses this statistic to compute the
   quantization parameters.
Parameters:
      * dtype -- dtype argument to the quantize node needed to
        implement the reference model spec.
  * **qscheme** -- Quantization scheme to be used

  * **reduce_range** -- Reduces the range of the quantized data
    type by 1 bit

  * **quant_min** -- Minimum quantization value. If unspecified,
    it will follow the 8-bit setup.
it will follow the 8-bit setup.
  * **quant_max** -- Maximum quantization value. If unspecified,
    it will follow the 8-bit setup.

  * **eps** (*Tensor*) -- Epsilon value for float32, Defaults to
    *torch.finfo(torch.float32).eps*.

Given running min/max as x_\text{min} and x_\text{max}, scale s and
   zero point z are computed as:
The running minimum/maximum x_\text{min/max} is computed as:
  \begin{array}{ll} x_\text{min} &= \begin{cases}     \min(X) &
  \text{if~}x_\text{min} = \text{None} \\
  \min\left(x_\text{min}, \min(X)\right) & \text{otherwise}
  \end{cases}\\ x_\text{max} &= \begin{cases}     \max(X) &
  \text{if~}x_\text{max} = \text{None} \\
  \max\left(x_\text{max}, \max(X)\right) & \text{otherwise}
  \end{cases}\\ \end{array}

where X is the observed tensor.
The scale s and zero point z are then computed as:
  \begin{aligned}     \text{if Symmetric:}&\\     &s = 2
\max(|x_\text{min}|, x_\text{max}) /         \left( Q_\text{max}
      - Q_\text{min} \right) \     &z = \begin{cases}         0 &
      \text{if dtype is qint8} \         128 & \text{otherwise}
      \end{cases}\     \text{Otherwise:}&\         &s = \left(
      x_\text{max} - x_\text{min}  \right ) /             \left(
      Q_\text{max} - Q_\text{min} \right ) \         &z =
      Q_\text{min} - \text{round}(x_\text{min} / s) \end{aligned}
where Q_\text{min} and Q_\text{max} are the minimum and maximum of
   the quantized data type.
Warning:
 "dtype" can only take "torch.qint8" or "torch.quint8".

Note:
 If the running minimum equals to the running maximum, the scale
 and zero_point are set to 1.0 and 0.

calculate_qparams()
  Calculates the quantization parameters.

forward(x_orig)
  Records the running minimum and maximum of "x".

reset_min_max_vals()
  Resets the min/max values.
torch.cosh
torch.cosh(input, *, out=None) -> Tensor
Returns a new tensor with the hyperbolic cosine  of the elements of
   "input".
  \text{out}_{i} = \cosh(\text{input}_{i})

Parameters:
      input (Tensor) -- the input tensor.
Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> a = torch.randn(4)
  >>> a
  tensor([ 0.1632,  1.1835, -0.6979, -0.7325])
  >>> torch.cosh(a)
  tensor([ 1.0133,  1.7860,  1.2536,  1.2805])

Note:
 When "input" is on the CPU, the implementation of torch.cosh may
 use the Sleef library, which rounds very large results to
 infinity or negative infinity. See here for details.
torch.msort
torch.msort(input, *, out=None) -> Tensor
Sorts the elements of the "input" tensor along its first dimension
   in ascending order by value.
Note:
 *torch.msort(t)* is equivalent to *torch.sort(t, dim=0)[0]*. See
 also "torch.sort()".

Parameters:
      input (Tensor) -- the input tensor.
Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> t = torch.randn(3, 4)
  >>> t
  tensor([[-0.1321,  0.4370, -1.2631, -1.1289],
          [-2.0527, -1.1250,  0.2275,  0.3077],
          [-0.0881, -0.1259, -0.5495,  1.0284]])
  >>> torch.msort(t)
  tensor([[-2.0527, -1.1250, -1.2631, -1.1289],
          [-0.1321, -0.1259, -0.5495,  0.3077],
          [-0.0881,  0.4370,  0.2275,  1.0284]])
GroupNorm
class torch.ao.nn.quantized.GroupNorm(num_groups, num_channels, weight, bias, scale, zero_point, eps=1e-05, affine=True, device=None, dtype=None)
This is the quantized version of "GroupNorm".
Additional args:
      * scale - quantization scale of the output, type: double.
  * **zero_point** - quantization zero point of the output, type:
    long.
torch.nn.functional.cosine_similarity
torch.nn.functional.cosine_similarity(x1, x2, dim=1, eps=1e-8) -> Tensor
Returns cosine similarity between "x1" and "x2", computed along
   dim. "x1" and "x2" must be broadcastable to a common shape. "dim"
   refers to the dimension in this common shape. Dimension "dim" of
   the output is squeezed (see "torch.squeeze()"), resulting in the
   output tensor having 1 fewer dimension.
  \text{similarity} = \dfrac{x_1 \cdot x_2}{\max(\Vert x_1 \Vert
  _2 \cdot \Vert x_2 \Vert _2, \epsilon)}

Supports type promotion.
Parameters:
      * x1 (Tensor) -- First input.
  * **x2** (*Tensor*) -- Second input.

  * **dim** (*int**, **optional*) -- Dimension along which cosine
    similarity is computed. Default: 1

  * **eps** (*float**, **optional*) -- Small value to avoid
    division by zero. Default: 1e-8

Example:
  >>> input1 = torch.randn(100, 128)
torch.signal.windows.general_cosine
torch.signal.windows.general_cosine(M, *, a, sym=True, dtype=None, layout=torch.strided, device=None, requires_grad=False)
Computes the general cosine window.
The general cosine window is defined as follows:
  w_n = \sum^{M-1}_{i=0} (-1)^i a_i \cos{ \left( \frac{2 \pi i
  n}{M - 1}\right)}

The window is normalized to 1 (maximum value is 1). However, the 1
   doesn't appear if "M" is even and "sym" is True.
Parameters:
      M (int) -- the length of the window. In other words, the
      number of points of the returned window.
Keyword Arguments:
      * a (Iterable) -- the coefficients associated to each of
        the cosine functions.
  * **sym** (*bool**, **optional*) -- If *False*, returns a
    periodic window suitable for use in spectral analysis. If
    *True*, returns a symmetric window suitable for use in filter
    design. Default: *True*.
design. Default: True.
  * **dtype** ("torch.dtype", optional) -- the desired data type
    of returned tensor. Default: if "None", uses a global default
    (see "torch.set_default_tensor_type()").

  * **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".

Return type:
      Tensor
Examples:
  >>> # Generates a symmetric general cosine window with 3 coefficients.
torch.signal.windows.general_cosine(10, a=[0.46, 0.23, 0.31], sym=True)
      tensor([0.5400, 0.3376, 0.1288, 0.4200, 0.9136, 0.9136, 0.4200, 0.1288, 0.3376, 0.5400])



  >>> # Generates a periodic general cosine window wit 2 coefficients.
  >>> torch.signal.windows.general_cosine(10, a=[0.5, 1 - 0.5], sym=False)
  tensor([0.0000, 0.0955, 0.3455, 0.6545, 0.9045, 1.0000, 0.9045, 0.6545, 0.3455, 0.0955])
torch.block_diag
torch.block_diag(*tensors)
Create a block diagonal matrix from provided tensors.
Parameters:
      *tensors -- One or more tensors with 0, 1, or 2 dimensions.
Returns:
      A 2 dimensional tensor with all the input tensors arranged in
      order such that their upper left and lower right corners are
      diagonally adjacent. All other elements are set to 0.
Return type:
      Tensor
Example:
  >>> import torch
  >>> A = torch.tensor([[0, 1], [1, 0]])
  >>> B = torch.tensor([[3, 4, 5], [6, 7, 8]])
  >>> C = torch.tensor(7)
  >>> D = torch.tensor([1, 2, 3])
  >>> E = torch.tensor([[4], [5], [6]])
  >>> torch.block_diag(A, B, C, D, E)
  tensor([[0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
          [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 3, 4, 5, 0, 0, 0, 0, 0],
          [0, 0, 6, 7, 8, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 7, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 1, 2, 3, 0],
[0, 0, 0, 0, 0, 0, 1, 2, 3, 0],
              [0, 0, 0, 0, 0, 0, 0, 0, 0, 4],
              [0, 0, 0, 0, 0, 0, 0, 0, 0, 5],
              [0, 0, 0, 0, 0, 0, 0, 0, 0, 6]])
torch.nn.functional.max_pool3d
torch.nn.functional.max_pool3d(input, kernel_size, stride=None, padding=0, dilation=1, ceil_mode=False, return_indices=False)
Applies a 3D max pooling over an input signal composed of several
   input planes.
Note:
 The order of "ceil_mode" and "return_indices" is different from
 what seen in "MaxPool3d", and will change in a future release.

See "MaxPool3d" for details.
Parameters:
      * input -- input tensor (\text{minibatch} ,
        \text{in_channels} , iD, iH , iW), minibatch dim optional.
  * **kernel_size** -- size of the pooling region. Can be a single
    number or a tuple *(kT, kH, kW)*

  * **stride** -- stride of the pooling operation. Can be a single
    number or a tuple *(sT, sH, sW)*. Default: "kernel_size"

  * **padding** -- Implicit negative infinity padding to be added
    on both sides, must be >= 0 and <= kernel_size / 2.
dilation -- The stride between elements within a sliding
        window, must be > 0.


ceil_mode -- If "True", will use ceil instead of floor
    to compute the output shape. This ensures that every element
    in the input tensor is covered by a sliding window.


return_indices -- If "True", will return the argmax along
    with the max values. Useful for
    "torch.nn.functional.max_unpool3d" later
enable_grad
class torch.enable_grad
Context-manager that enables gradient calculation.
Enables gradient calculation, if it has been disabled via "no_grad"
   or "set_grad_enabled".
This context manager is thread local; it will not affect
   computation in other threads.
Also functions as a decorator. (Make sure to instantiate with
   parenthesis.)
Note:
 enable_grad is one of several mechanisms that can enable or
 disable gradients locally see Locally disabling gradient
 computation for more information on how they compare.

Note:
 This API does not apply to forward-mode AD.

Example::
      >>> x = torch.tensor([1.], requires_grad=True)
      >>> with torch.no_grad():
      ...     with torch.enable_grad():
      ...         y = x * 2
      >>> y.requires_grad
      True
      >>> y.backward()
      >>> x.grad
      tensor([2.])
      >>> @torch.enable_grad()
      ... def doubler(x):
      ...     return x * 2
      >>> with torch.no_grad():
InstanceNorm2d
class torch.nn.InstanceNorm2d(num_features, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False, device=None, dtype=None)
Applies Instance Normalization over a 4D input (a mini-batch of 2D
   inputs with additional channel dimension) as described in the paper
   Instance Normalization: The Missing Ingredient for Fast
   Stylization.
  y = \frac{x - \mathrm{E}[x]}{ \sqrt{\mathrm{Var}[x] + \epsilon}}
  * \gamma + \beta

The mean and standard-deviation are calculated per-dimension
   separately for each object in a mini-batch. \gamma and \beta are
   learnable parameter vectors of size C (where C is the input
   size) if "affine" is "True". The standard-deviation is calculated
   via the biased estimator, equivalent to torch.var(input,
   unbiased=False).
By default, this layer uses instance statistics computed from input
   data in both training and evaluation modes.
If "track_running_stats" is set to "True", during training this
layer keeps running estimates of its computed mean and variance,
   which are then used for normalization during evaluation. The
   running estimates are kept with a default "momentum" of 0.1.
Note:
 This "momentum" argument is different from one used in optimizer
 classes and the conventional notion of momentum. Mathematically,
 the update rule for running statistics here is \hat{x}_\text{new}
 = (1 - \text{momentum}) \times \hat{x} + \text{momentum} \times
 x_t, where \hat{x} is the estimated statistic and x_t is the new
 observed value.

Note:
 "InstanceNorm2d" and "LayerNorm" are very similar, but have some
 subtle differences. "InstanceNorm2d" is applied on each channel
 of channeled data like RGB images, but "LayerNorm" is usually
 applied on entire sample and often in NLP tasks. Additionally,
 "LayerNorm" applies elementwise affine transform, while
 "InstanceNorm2d" usually don't apply affine transform.

Parameters:
Parameters:
      * num_features (int) -- C from an expected input of size
        (N, C, H, W) or (C, H, W)
  * **eps** (*float*) -- a value added to the denominator for
    numerical stability. Default: 1e-5

  * **momentum** (*float*) -- the value used for the running_mean
    and running_var computation. Default: 0.1

  * **affine** (*bool*) -- a boolean value that when set to
    "True", this module has learnable affine parameters,
    initialized the same way as done for batch normalization.
    Default: "False".

  * **track_running_stats** (*bool*) -- a boolean value that when
    set to "True", this module tracks the running mean and
    variance, and when set to "False", this module does not track
    such statistics and always uses batch statistics in both
    training and eval modes. Default: "False"

Shape:
      * Input: (N, C, H, W) or (C, H, W)
  * Output: (N, C, H, W) or (C, H, W) (same shape as input)

Examples:
torch.cholesky
torch.cholesky(input, upper=False, *, out=None) -> Tensor
Computes the Cholesky decomposition of a symmetric positive-
   definite matrix A or for batches of symmetric positive-definite
   matrices.
If "upper" is "True", the returned matrix "U" is upper-triangular,
   and the decomposition has the form:
  A = U^TU

If "upper" is "False", the returned matrix "L" is lower-triangular,
   and the decomposition has the form:
  A = LL^T

If "upper" is "True", and A is a batch of symmetric positive-
   definite matrices, then the returned tensor will be composed of
   upper-triangular Cholesky factors of each of the individual
   matrices. Similarly, when "upper" is "False", the returned tensor
   will be composed of lower-triangular Cholesky factors of each of
   the individual matrices.
Warning:
 "torch.cholesky()" is deprecated in favor of
 "torch.linalg.cholesky()" and will be removed in a future PyTorch
release."L = torch.cholesky(A)" should be replaced with
    L = torch.linalg.cholesky(A)

 "U = torch.cholesky(A, upper=True)" should be replaced with

    U = torch.linalg.cholesky(A).mH

 This transform will produce equivalent results for all valid
 (symmetric positive definite) inputs.

Parameters:
      * input (Tensor) -- the input tensor A of size (*, n, n)
        where *** is zero or more batch dimensions consisting of
        symmetric positive-definite matrices.
  * **upper** (*bool**, **optional*) -- flag that indicates
    whether to return a upper or lower triangular matrix. Default:
    "False"

Keyword Arguments:
      out (Tensor, optional) -- the output matrix
Example:
  >>> a = torch.randn(3, 3)
  >>> a = a @ a.mT + 1e-3 # make symmetric positive-definite
  >>> l = torch.cholesky(a)
  >>> a
  tensor([[ 2.4112, -0.7486,  1.4551],
          [-0.7486,  1.3544,  0.1294],
[-0.7486,  1.3544,  0.1294],
              [ 1.4551,  0.1294,  1.6724]])
      >>> l
      tensor([[ 1.5528,  0.0000,  0.0000],
              [-0.4821,  1.0592,  0.0000],
              [ 0.9371,  0.5487,  0.7023]])
      >>> l @ l.mT
      tensor([[ 2.4112, -0.7486,  1.4551],
              [-0.7486,  1.3544,  0.1294],
              [ 1.4551,  0.1294,  1.6724]])
      >>> a = torch.randn(3, 2, 2) # Example for batched input
      >>> a = a @ a.mT + 1e-03 # make symmetric positive-definite
      >>> l = torch.cholesky(a)
      >>> z = l @ l.mT
      >>> torch.dist(z, a)
      tensor(2.3842e-07)
torch.narrow_copy
torch.narrow_copy(input, dim, start, length, *, out=None) -> Tensor
Same as "Tensor.narrow()" except this returns a copy rather than
   shared storage. This is primarily for sparse tensors, which do not
   have a shared-storage narrow method.
Parameters:
      * input (Tensor) -- the tensor to narrow
  * **dim** (*int*) -- the dimension along which to narrow

  * **start** (*int*) -- index of the element to start the
    narrowed dimension from. Can be negative, which means indexing
    from the end of *dim*

  * **length** (*int*) -- length of the narrowed dimension, must
    be weakly positive

Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> x = torch.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
  >>> torch.narrow_copy(x, 0, 0, 2)
  tensor([[ 1,  2,  3],
          [ 4,  5,  6]])
  >>> torch.narrow_copy(x, 1, 1, 2)
  tensor([[ 2,  3],
          [ 5,  6],
tensor([[ 2,  3],
              [ 5,  6],
              [ 8,  9]])
      >>> s = torch.arange(16).reshape(2, 2, 2, 2).to_sparse(2)
      >>> torch.narrow_copy(s, 0, 0, 1)
      tensor(indices=tensor([[0, 0],
                             [0, 1]]),
             values=tensor([[[0, 1],
                             [2, 3]],
                        [[4, 5],
                         [6, 7]]]),
         size=(1, 2, 2, 2), nnz=2, layout=torch.sparse_coo)

See also: "torch.narrow()" for a non copy variant
torch.nn.utils.parametrizations.spectral_norm
torch.nn.utils.parametrizations.spectral_norm(module, name='weight', n_power_iterations=1, eps=1e-12, dim=None)
Applies spectral normalization to a parameter in the given module.
  \mathbf{W}_{SN} = \dfrac{\mathbf{W}}{\sigma(\mathbf{W})},
  \sigma(\mathbf{W}) = \max_{\mathbf{h}: \mathbf{h} \ne 0}
  \dfrac{\|\mathbf{W} \mathbf{h}\|_2}{\|\mathbf{h}\|_2}

When applied on a vector, it simplifies to
  \mathbf{x}_{SN} = \dfrac{\mathbf{x}}{\|\mathbf{x}\|_2}

Spectral normalization stabilizes the training of discriminators
   (critics) in Generative Adversarial Networks (GANs) by reducing the
   Lipschitz constant of the model. \sigma is approximated performing
   one iteration of the power method every time the weight is
   accessed. If the dimension of the weight tensor is greater than 2,
   it is reshaped to 2D in power iteration method to get spectral
   norm.
norm.
See Spectral Normalization for Generative Adversarial Networks .
Note:
 This function is implemented using the parametrization
 functionality in "register_parametrization()". It is a
 reimplementation of "torch.nn.utils.spectral_norm()".

Note:
 When this constraint is registered, the singular vectors
 associated to the largest singular value are estimated rather
 than sampled at random. These are then updated performing
 "n_power_iterations" of the power method whenever the tensor is
 accessed with the module on *training* mode.

Note:
 If the *_SpectralNorm* module, i.e.,
 *module.parametrization.weight[idx]*, is in training mode on
 removal, it will perform another power iteration. If you'd like
 to avoid this iteration, set the module to eval mode before its
 removal.

Parameters:
      * module (nn.Module) -- containing module
  * **name** (*str**, **optional*) -- name of weight parameter.