shrinath-suresh/blogs-docs-splitted huggingface dataset:
found in the dimension "dim".
This function is identical to "torch.median()" when there are no
   "NaN" values in a reduced row. When a reduced row has one or more
   "NaN" values, "torch.median()" will always reduce it to "NaN",
   while this function will reduce it to the median of the non-"NaN"
   elements. If all the elements in a reduced row are "NaN" then it
   will be reduced to "NaN", too.
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, Tensor), optional) -- The first
      tensor will be populated with the median values and the second
      tensor, which must have dtype long, with their indices in the
      dimension "dim" of "input".
Example:
  >>> a = torch.tensor([[2, 3, 1], [float('nan'), 1, float('nan')]])
  >>> a
  tensor([[2., 3., 1.],
a
      tensor([[2., 3., 1.],
              [nan, 1., nan]])
      >>> a.median(0)
      torch.return_types.median(values=tensor([nan, 1., nan]), indices=tensor([1, 1, 1]))
      >>> a.nanmedian(0)
      torch.return_types.nanmedian(values=tensor([2., 1., 1.]), indices=tensor([0, 1, 0]))
EmbeddingBag
class torch.ao.nn.quantized.EmbeddingBag(num_embeddings, embedding_dim, max_norm=None, norm_type=2.0, scale_grad_by_freq=False, mode='sum', sparse=False, _weight=None, include_last_offset=False, dtype=torch.quint8)
A quantized EmbeddingBag module with quantized packed weights as
   inputs. We adopt the same interface as torch.nn.EmbeddingBag,
   please see
   https://pytorch.org/docs/stable/nn.html#torch.nn.EmbeddingBag for
   documentation.
Similar to "EmbeddingBag", attributes will be randomly initialized
   at module creation time and will be overwritten later
Variables:
      weight (Tensor) -- the non-learnable quantized weights of
      the module of shape (\text{num_embeddings},
      \text{embedding_dim}).
Examples::
      >>> m = nn.quantized.EmbeddingBag(num_embeddings=10, embedding_dim=12, include_last_offset=True, mode='sum')
indices = torch.tensor([9, 6, 5, 7, 8, 8, 9, 2, 8, 6, 6, 9, 1, 6, 8, 8, 3, 2, 3, 6, 3, 6, 5, 7, 0, 8, 4, 6, 5, 8, 2, 3])
      >>> offsets = torch.tensor([0, 19, 20, 28, 28, 32])
      >>> output = m(indices, offsets)
      >>> print(output.size())
      torch.Size([5, 12])



classmethod from_float(mod)
  Create a quantized embedding_bag module from a float module

  Parameters:
     **mod** (*Module*) -- a float module, either produced by
     torch.ao.quantization utilities or provided by user
torch.linalg.slogdet
torch.linalg.slogdet(A, *, out=None)
Computes the sign and natural logarithm of the absolute value of
   the determinant of a square matrix.
For complex "A", it returns the sign and the natural logarithm of
   the modulus of the determinant, that is, a logarithmic polar
   decomposition of the determinant.
The determinant can be recovered as sign * exp(logabsdet). When a
   matrix has a determinant of zero, it returns (0, -inf).
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.
See also:
 "torch.linalg.det()" computes the determinant of square matrices.

Parameters:
      A (Tensor) -- tensor of shape (, n, n)* where *** is
      zero or more batch dimensions.
Keyword Arguments:
      out (tuple, optional) -- output tuple of two tensors.
      Ignored if None. Default: None.
Ignored if None. Default: None.
Returns:
      A named tuple (sign, logabsdet).
  *sign* will have the same dtype as "A".

  *logabsdet* will always be real-valued, even when "A" is
  complex.

Examples:
  >>> A = torch.randn(3, 3)
  >>> A
  tensor([[ 0.0032, -0.2239, -1.1219],
          [-0.6690,  0.1161,  0.4053],
          [-1.6218, -0.9273, -0.0082]])
  >>> torch.linalg.det(A)
  tensor(-0.7576)
  >>> torch.logdet(A)
  tensor(nan)
  >>> torch.linalg.slogdet(A)
  torch.return_types.linalg_slogdet(sign=tensor(-1.), logabsdet=tensor(-0.2776))
torch.float_power
torch.float_power(input, exponent, *, out=None) -> Tensor
Raises "input" to the power of "exponent", elementwise, in double
   precision. If neither input is complex returns a "torch.float64"
   tensor, and if one or more inputs is complex returns a
   "torch.complex128" tensor.
Note:
 This function always computes in double precision, unlike
 "torch.pow()", which implements more typical type promotion. This
 is useful when the computation needs to be performed in a wider
 or more precise dtype, or the results of the computation may
 contain fractional values not representable in the input dtypes,
 like when an integer base is raised to a negative integer
 exponent.

Parameters:
      * input (Tensor or Number) -- the base value(s)
  * **exponent** (*Tensor** or **Number*) -- the exponent value(s)

Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
Example:
  >>> a = torch.randint(10, (4,))
  >>> a
  tensor([6, 4, 7, 1])
  >>> torch.float_power(a, 2)
  tensor([36., 16., 49.,  1.], dtype=torch.float64)

  >>> a = torch.arange(1, 5)
  >>> a
  tensor([ 1,  2,  3,  4])
  >>> exp = torch.tensor([2, -3, 4, -5])
  >>> exp
  tensor([ 2, -3,  4, -5])
  >>> torch.float_power(a, exp)
  tensor([1.0000e+00, 1.2500e-01, 8.1000e+01, 9.7656e-04], dtype=torch.float64)
torch.istft
torch.istft(input, n_fft, hop_length=None, win_length=None, window=None, center=True, normalized=False, onesided=None, length=None, return_complex=False) -> Tensor:
Inverse short time Fourier Transform. This is expected to be the
   inverse of "stft()".
It has the same parameters (+ additional optional parameter of
   "length") and it should return the least squares estimation of the
   original signal. The algorithm will check using the NOLA condition
   ( nonzero overlap).
Important consideration in the parameters "window" and "center" so
   that the envelop created by the summation of all the windows is
   never zero at certain point in time. Specifically,
   \sum_{t=-\infty}^{\infty} |w|^2[n-t\times hop_length] \cancel{=}
   0.
Since "stft()" discards elements at the end of the signal if they
   do not fit in a frame, "istft" may return a shorter signal than the
   original signal (can occur if "center" is False since the signal
isn't padded). If length is given in the arguments and is longer
   than expected, "istft" will pad zeros to the end of the returned
   signal.
If "center" is "True", then there will be padding e.g.
   "'constant'", "'reflect'", etc. Left padding can be trimmed off
   exactly because they can be calculated but right padding cannot be
   calculated without additional information.
Example: Suppose the last window is: "[17, 18, 0, 0, 0]" vs "[18,
   0, 0, 0, 0]"
The "n_fft", "hop_length", "win_length" are all the same which
   prevents the calculation of right padding. These additional values
   could be zeros or a reflection of the signal so providing "length"
   could be useful. If "length" is "None" then padding will be
   aggressively removed (some loss of signal).
[1] D. W. Griffin and J. S. Lim, "Signal estimation from modified
   short-time Fourier transform," IEEE Trans. ASSP, vol.32, no.2,
   pp.236-243, Apr. 1984.
Parameters:
      * input (Tensor) --
Parameters:
      * input (Tensor) --
    The input tensor. Expected to be in the format of "stft()",
    output. That is a complex tensor of shape ("channel",
    "fft_size", "n_frame"), where the "channel" dimension is
    optional.

    Changed in version 2.0: Real datatype inputs are no longer
    supported. Input must now have a complex datatype, as returned
    by "stft(..., return_complex=True)".

  * **n_fft** (*int*) -- Size of Fourier transform

  * **hop_length** (*Optional**[**int**]*) -- The distance between
    neighboring sliding window frames. (Default: "n_fft // 4")

  * **win_length** (*Optional**[**int**]*) -- The size of window
    frame and STFT filter. (Default: "n_fft")

  * **window** (*Optional**[**torch.Tensor**]*) -- The optional
    window function. (Default: "torch.ones(win_length)")

  * **center** (*bool*) -- Whether "input" was padded on both
    sides so that the t-th frame is centered at time t \times
\text{hop_length}. (Default: "True")
  * **normalized** (*bool*) -- Whether the STFT was normalized.
    (Default: "False")

  * **onesided** (*Optional**[**bool**]*) -- Whether the STFT was
    onesided. (Default: "True" if "n_fft != fft_size" in the input
    size)

  * **length** (*Optional**[**int**]*) -- The amount to trim the
    signal by (i.e. the original signal length). (Default: whole
    signal)

  * **return_complex** (*Optional**[**bool**]*) -- Whether the
    output should be complex, or if the input should be assumed to
    derive from a real signal and window. Note that this is
    incompatible with "onesided=True". (Default: "False")

Returns:
      Least squares estimation of the original signal of size (...,
      signal_length)
Return type:
      Tensor
Softmax
class torch.nn.Softmax(dim=None)
Applies the Softmax 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.
Softmax is defined as:
  \text{Softmax}(x_{i}) = \frac{\exp(x_i)}{\sum_j \exp(x_j)}

When the input Tensor is a sparse tensor then the unspecified
   values are treated as "-inf".
Shape:
      * Input: (*) where *** means, any number of additional
        dimensions
  * Output: (*), same shape as the input

Returns:
      a Tensor of the same dimension and shape as the input with
      values in the range [0, 1]
Parameters:
      dim (int) -- A dimension along which Softmax will be
      computed (so every slice along dim will sum to 1).
Return type:
      None
Note:
 This module doesn't work directly with NLLLoss, which expects the
 Log to be computed between the Softmax and itself. Use
torch.empty_like
torch.empty_like(input, *, dtype=None, layout=None, device=None, requires_grad=False, memory_format=torch.preserve_format) -> Tensor
Returns an uninitialized tensor with the same size as "input".
   "torch.empty_like(input)" is equivalent to
   "torch.empty(input.size(), dtype=input.dtype, layout=input.layout,
   device=input.device)".
Parameters:
      input (Tensor) -- the size of "input" will determine size
      of the output tensor.
Keyword Arguments:
      * dtype ("torch.dtype", optional) -- the desired data type
        of returned Tensor. Default: if "None", defaults to the dtype
        of "input".
  * **layout** ("torch.layout", optional) -- the desired layout of
    returned tensor. Default: if "None", defaults to the layout of
    "input".

  * **device** ("torch.device", optional) -- the desired device of
    returned tensor. Default: if "None", defaults to the device of
    "input".
"input".
  * **requires_grad** (*bool**, **optional*) -- If autograd should
    record operations on the returned tensor. Default: "False".

  * **memory_format** ("torch.memory_format", optional) -- the
    desired memory format of returned Tensor. Default:
    "torch.preserve_format".

Example:
  >>> a=torch.empty((2,3), dtype=torch.int32, device = 'cuda')
  >>> torch.empty_like(a)
  tensor([[0, 0, 0],
          [0, 0, 0]], device='cuda:0', dtype=torch.int32)
torch.linalg.matrix_exp
torch.linalg.matrix_exp(A) -> Tensor
Computes the matrix exponential of a square matrix.
Letting \mathbb{K} be \mathbb{R} or \mathbb{C}, this function
   computes the matrix exponential of A \in \mathbb{K}^{n \times
   n}, which is defined as
  \mathrm{matrix_exp}(A) = \sum_{k=0}^\infty \frac{1}{k!}A^k \in
  \mathbb{K}^{n \times n}.

If the matrix A has eigenvalues \lambda_i \in \mathbb{C}, the
   matrix \mathrm{matrix_exp}(A) has eigenvalues e^{\lambda_i} \in
   \mathbb{C}.
Supports input of bfloat16, 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.
Parameters:
      A (Tensor) -- tensor of shape (, n, n)* where *** is
      zero or more batch dimensions.
Example:
  >>> A = torch.empty(2, 2, 2)
  >>> A[0, :, :] = torch.eye(2, 2)
  >>> A[1, :, :] = 2 * torch.eye(2, 2)
  >>> A
A
      tensor([[[1., 0.],
               [0., 1.]],



          [[2., 0.],
           [0., 2.]]])
  >>> torch.linalg.matrix_exp(A)
  tensor([[[2.7183, 0.0000],
           [0.0000, 2.7183]],

           [[7.3891, 0.0000],
            [0.0000, 7.3891]]])

  >>> import math
  >>> A = torch.tensor([[0, math.pi/3], [-math.pi/3, 0]]) # A is skew-symmetric
  >>> torch.linalg.matrix_exp(A) # matrix_exp(A) = [[cos(pi/3), sin(pi/3)], [-sin(pi/3), cos(pi/3)]]
  tensor([[ 0.5000,  0.8660],
          [-0.8660,  0.5000]])
torch.jit.unused
torch.jit.unused(fn)
This decorator indicates to the compiler that a function or method
   should be ignored and replaced with the raising of an exception.
   This allows you to leave code in your model that is not yet
   TorchScript compatible and still export your model.
  Example (using "@torch.jit.unused" on a method):

     import torch
     import torch.nn as nn

     class MyModule(nn.Module):
         def __init__(self, use_memory_efficient):
             super(MyModule, self).__init__()
             self.use_memory_efficient = use_memory_efficient

         @torch.jit.unused
         def memory_efficient(self, x):
             import pdb
             pdb.set_trace()
             return x + 10

         def forward(self, x):
             # Use not-yet-scriptable memory efficient mode
             if self.use_memory_efficient:
                 return self.memory_efficient(x)
             else:
fuse_modules
class torch.quantization.fuse_modules(model, modules_to_fuse, inplace=False, fuser_func=, fuse_custom_config_dict=None)
Fuses a list of modules into a single module
Fuses only the following sequence of modules: conv, bn conv, bn,
   relu conv, relu linear, relu bn, relu All other sequences are left
   unchanged. For these sequences, replaces the first item in the list
   with the fused module, replacing the rest of the modules with
   identity.
Parameters:
      * model -- Model containing the modules to be fused
  * **modules_to_fuse** -- list of list of module names to fuse.
    Can also be a list of strings if there is only a single list
    of modules to fuse.

  * **inplace** -- bool specifying if fusion happens in place on
    the model, by default a new model is returned

  * **fuser_func** -- Function that takes in a list of modules and
    outputs a list of fused modules of the same length. For
example, fuser_func([convModule, BNModule]) returns the list
        [ConvBNModule, nn.Identity()] Defaults to
        torch.ao.quantization.fuse_known_modules
  * **fuse_custom_config_dict** -- custom configuration for fusion

  # Example of fuse_custom_config_dict
  fuse_custom_config_dict = {
      # Additional fuser_method mapping
      "additional_fuser_method_mapping": {
          (torch.nn.Conv2d, torch.nn.BatchNorm2d): fuse_conv_bn
      },
  }

Returns:
      model with fused modules. A new copy is created if inplace=True.
Examples:
  >>> m = M().eval()
  >>> # m is a module containing the sub-modules below
  >>> modules_to_fuse = [ ['conv1', 'bn1', 'relu1'], ['submodule.conv', 'submodule.relu']]
  >>> fused_m = torch.ao.quantization.fuse_modules(m, modules_to_fuse)
  >>> output = fused_m(input)

  >>> m = M().eval()
  >>> # Alternately provide a single list of modules to fuse
torch.round
torch.round(input, *, decimals=0, out=None) -> Tensor
Rounds elements of "input" to the nearest integer.
For integer inputs, follows the array-api convention of returning a
   copy of the input tensor.
Note:
 This function implements the "round half to even" to break ties
 when a number is equidistant from two integers (e.g. *round(2.5)*
 is 2).When the :attr:`decimals` argument is specified the
 algorithm used is similar to NumPy's *around*. This algorithm is
 fast but inexact and it can easily overflow for low precision
 dtypes. Eg. *round(tensor([10000], dtype=torch.float16),
 decimals=3)* is *inf*.

See also:
 "torch.ceil()", which rounds up. "torch.floor()", which rounds
 down. "torch.trunc()", which rounds towards zero.

Parameters:
      * input (Tensor) -- the input tensor.
  * **decimals** (*int*) -- Number of decimal places to round to
    (default: 0). If decimals is negative, it specifies the number
of positions to the left of the decimal point.
Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> torch.round(torch.tensor((4.7, -2.3, 9.1, -7.7)))
  tensor([ 5.,  -2.,  9., -8.])

  >>> # Values equidistant from two integers are rounded towards the
  >>> #   the nearest even value (zero is treated as even)
  >>> torch.round(torch.tensor([-0.5, 0.5, 1.5, 2.5]))
  tensor([-0., 0., 2., 2.])

  >>> # A positive decimals argument rounds to the to that decimal place
  >>> torch.round(torch.tensor([0.1234567]), decimals=3)
  tensor([0.1230])

  >>> # A negative decimals argument rounds to the left of the decimal
  >>> torch.round(torch.tensor([1200.1234567]), decimals=-3)
  tensor([1000.])
torch.is_tensor
torch.is_tensor(obj)
Returns True if obj is a PyTorch tensor.
Note that this function is simply doing "isinstance(obj, Tensor)".
   Using that "isinstance" check is better for typechecking with mypy,
   and more explicit - so it's recommended to use that instead of
   "is_tensor".
Parameters:
      obj (Object) -- Object to test
Example:
  >>> x = torch.tensor([1, 2, 3])
  >>> torch.is_tensor(x)
  True
FractionalMaxPool2d
class torch.nn.FractionalMaxPool2d(kernel_size, output_size=None, output_ratio=None, return_indices=False, _random_samples=None)
Applies a 2D fractional max pooling over an input signal composed
   of several input planes.
Fractional MaxPooling is described in detail in the paper
   Fractional MaxPooling by Ben Graham
The max-pooling operation is applied in kH \times kW regions by a
   stochastic step size determined by the target output size. The
   number of output features is equal to the number of input planes.
Parameters:
      * kernel_size (Union[int, Tuple[int,
        int]]) -- the size of the window to take a max over.
        Can be a single number k (for a square kernel of k x k) or a
        tuple (kh, kw)
  * **output_size** (*Union**[**int**, **Tuple**[**int**,
    **int**]**]*) -- the target output size of the image of the
    form *oH x oW*. Can be a tuple *(oH, oW)* or a single number
oH for a square image oH x oH
  * **output_ratio** (*Union**[**float**, **Tuple**[**float**,
    **float**]**]*) -- If one wants to have an output size as a
    ratio of the input size, this option can be given. This has to
    be a number or tuple in the range (0, 1)

  * **return_indices** (*bool*) -- if "True", will return the
    indices along with the outputs. Useful to pass to
    "nn.MaxUnpool2d()". Default: "False"

Shape:
      * Input: (N, C, H_{in}, W_{in}) or (C, H_{in}, W_{in}).
  * Output: (N, C, H_{out}, W_{out}) or (C, H_{out}, W_{out}),
    where (H_{out}, W_{out})=\text{output\_size} or (H_{out},
    W_{out})=\text{output\_ratio} \times (H_{in}, W_{in}).

-[ Examples ]-



pool of square window of size=3, and target output size 13x12
m = nn.FractionalMaxPool2d(3, output_size=(13, 12))
pool of square window and target output size being half of input image size
torch.repeat_interleave
torch.repeat_interleave(input, repeats, dim=None, *, output_size=None) -> Tensor
Repeat elements of a tensor.
Warning:
 This is different from "torch.Tensor.repeat()" but similar to
 "numpy.repeat".

Parameters:
      * input (Tensor) -- the input tensor.
  * **repeats** (*Tensor** or **int*) -- The number of repetitions
    for each element. repeats is broadcasted to fit the shape of
    the given axis.

  * **dim** (*int**, **optional*) -- The dimension along which to
    repeat values. By default, use the flattened input array, and
    return a flat output array.

Keyword Arguments:
      output_size (int, optional) -- Total output size for
      the given axis ( e.g. sum of repeats). If given, it will avoid
      stream synchronization needed to calculate output shape of the
      tensor.
Returns:
      Repeated tensor which has the same shape as input, except along
      the given axis.
the given axis.
Return type:
      Tensor
Example:
  >>> x = torch.tensor([1, 2, 3])
  >>> x.repeat_interleave(2)
  tensor([1, 1, 2, 2, 3, 3])
  >>> y = torch.tensor([[1, 2], [3, 4]])
  >>> torch.repeat_interleave(y, 2)
  tensor([1, 1, 2, 2, 3, 3, 4, 4])
  >>> torch.repeat_interleave(y, 3, dim=1)
  tensor([[1, 1, 1, 2, 2, 2],
          [3, 3, 3, 4, 4, 4]])
  >>> torch.repeat_interleave(y, torch.tensor([1, 2]), dim=0)
  tensor([[1, 2],
          [3, 4],
          [3, 4]])
  >>> torch.repeat_interleave(y, torch.tensor([1, 2]), dim=0, output_size=3)
  tensor([[1, 2],
          [3, 4],
          [3, 4]])

torch.repeat_interleave(repeats, *, output_size=None) -> Tensor
If the repeats is tensor([n1, n2, n3, ...]), then the output
   will be tensor([0, 0, ..., 1, 1, ..., 2, 2, ..., ...]) where 0
   appears n1 times, 1 appears n2 times, 2 appears n3 times,
   etc.
torch.clamp
torch.clamp(input, min=None, max=None, *, out=None) -> Tensor
Clamps all elements in "input" into the range [ "min", "max" ].
   Letting min_value and max_value be "min" and "max", respectively,
   this returns:
  y_i = \min(\max(x_i, \text{min\_value}_i), \text{max\_value}_i)

If "min" is "None", there is no lower bound. Or, if "max" is "None"
   there is no upper bound.
Note:
 If "min" is greater than "max" "torch.clamp(..., min, max)" sets
 all elements in "input" to the value of "max".

Parameters:
      * input (Tensor) -- the input tensor.
  * **min** (*Number** or **Tensor**, **optional*) -- lower-bound
    of the range to be clamped to

  * **max** (*Number** or **Tensor**, **optional*) -- upper-bound
    of the range to be clamped to

Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> a = torch.randn(4)
  >>> a
  tensor([-1.7120,  0.1734, -0.0478, -0.0922])
tensor([-1.7120,  0.1734, -0.0478, -0.0922])
      >>> torch.clamp(a, min=-0.5, max=0.5)
      tensor([-0.5000,  0.1734, -0.0478, -0.0922])
  >>> min = torch.linspace(-1, 1, steps=4)
  >>> torch.clamp(a, min=min)
  tensor([-1.0000,  0.1734,  0.3333,  1.0000])
L1Unstructured
class torch.nn.utils.prune.L1Unstructured(amount)
Prune (currently unpruned) units in a tensor by zeroing out the
   ones with the lowest L1-norm.
Parameters:
      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.
classmethod apply(module, name, amount, importance_scores=None)
  Adds the forward pre-hook that enables pruning on the fly and
  the reparametrization of a tensor in terms of the original
  tensor and the pruning mask.

  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.
     * **importance_scores** (*torch.Tensor*) -- tensor of
       importance scores (of same shape as module parameter) used
       to compute mask for pruning. The values in this tensor
       indicate the importance of the corresponding elements in
       the parameter being pruned. If unspecified or None, the
       module parameter will be used in its place.

apply_mask(module)
  Simply handles the multiplication between the parameter being
  pruned and the generated mask. Fetches the mask and the original
  tensor from the module and returns the pruned version of the
  tensor.

  Parameters:
     **module** (*nn.Module*) -- module containing the tensor to
     prune

  Returns:
     pruned version of the input tensor

  Return type: