shrinath-suresh/blogs-docs-splitted huggingface dataset:
form oT x oH x oW. Can be a tuple (oT, oH, oW) or a single
        number oH for a square image oH x oH x oH
  * **output_ratio** (*Union**[**float**, **Tuple**[**float**,
    **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.MaxUnpool3d()". Default: "False"

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

-[ Examples ]-



pool of cubic window of size=3, and target output size 13x12x11
m = nn.FractionalMaxPool3d(3, output_size=(13, 12, 11))
pool of cubic window and target output size being half of input size
m = nn.FractionalMaxPool3d(3, output_ratio=(0.5, 0.5, 0.5))
input = torch.randn(20, 16, 50, 32, 16)
output = m(input)
torch.Tensor.col_indices
Tensor.col_indices() -> IntTensor
Returns the tensor containing the column indices of the "self"
   tensor when "self" is a sparse CSR tensor of layout "sparse_csr".
   The "col_indices" tensor is strictly of shape ("self".nnz()) and of
   type "int32" or "int64".  When using MKL routines such as sparse
   matrix multiplication, it is necessary to use "int32" indexing in
   order to avoid downcasting and potentially losing information.
Example::
      >>> csr = torch.eye(5,5).to_sparse_csr()
      >>> csr.col_indices()
      tensor([0, 1, 2, 3, 4], dtype=torch.int32)
torch.Tensor.unfold
Tensor.unfold(dimension, size, step) -> Tensor
Returns a view of the original tensor which contains all slices of
   size "size" from "self" tensor in the dimension "dimension".
Step between two slices is given by "step".
If sizedim is the size of dimension "dimension" for "self", the
   size of dimension "dimension" in the returned tensor will be
   (sizedim - size) / step + 1.
An additional dimension of size "size" is appended in the returned
   tensor.
Parameters:
      * dimension (int) -- dimension in which unfolding happens
  * **size** (*int*) -- the size of each slice that is unfolded

  * **step** (*int*) -- the step between each slice

Example:
  >>> x = torch.arange(1., 8)
  >>> x
  tensor([ 1.,  2.,  3.,  4.,  5.,  6.,  7.])
  >>> x.unfold(0, 2, 1)
  tensor([[ 1.,  2.],
          [ 2.,  3.],
          [ 3.,  4.],
          [ 4.,  5.],
          [ 5.,  6.],
Tanh
class torch.nn.Tanh
Applies the Hyperbolic Tangent (Tanh) function element-wise.
Tanh is defined as:
  \text{Tanh}(x) = \tanh(x) = \frac{\exp(x) - \exp(-x)} {\exp(x) +
  \exp(-x)}

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

[image]
Examples:
  >>> m = nn.Tanh()
  >>> input = torch.randn(2)
  >>> output = m(input)
torch.isinf
torch.isinf(input) -> Tensor
Tests if each element of "input" is infinite (positive or negative
   infinity) or not.
Note:
 Complex values are infinite when their real or imaginary part is
 infinite.

Parameters:
      input (Tensor) -- the input tensor.
Returns:
      A boolean tensor that is True where "input" is infinite and
      False elsewhere
Example:
  >>> torch.isinf(torch.tensor([1, float('inf'), 2, float('-inf'), float('nan')]))
  tensor([False,  True,  False,  True,  False])
Attribute
class torch.jit.Attribute(value, type)
This method is a pass-through function that returns value, mostly
   used to indicate to the TorchScript compiler that the left-hand
   side expression is a class instance attribute with type of type.
   Note that torch.jit.Attribute should only be used in init
   method of jit.ScriptModule subclasses.
Though TorchScript can infer correct type for most Python
   expressions, there are some cases where type inference can be
   wrong, including:


Empty containers like [] and {}, which TorchScript assumes to
     be container of Tensor


Optional types like Optional[T] but assigned a valid value of
     type T, TorchScript would assume it is type T rather than
     Optional[T]


In eager mode, it is simply a pass-through function that returns
   value without other implications.
Example:
  import torch
  from typing import Dict

  class AttributeModule(torch.jit.ScriptModule):
def init(self):
              super(AttributeModule, self).init()
              self.foo = torch.jit.Attribute(0.1, float)
          # we should be able to use self.foo as a float here
          assert 0.0 < self.foo

          self.names_ages = torch.jit.Attribute({}, Dict[str, int])
          self.names_ages["someone"] = 20
          assert isinstance(self.names_ages["someone"], int)

  m = AttributeModule()
  # m will contain two attributes
  # 1. foo of type float
  # 2. names_ages of type Dict[str, int]

Note: it's now preferred to instead use type annotations instead of
   torch.jit.Annotate:
  import torch
  from typing import Dict

  class AttributeModule(torch.nn.Module):
      names: Dict[str, int]

      def __init__(self):
          super(AttributeModule, self).__init__()
          self.names = {}

  m = AttributeModule()

Parameters:
      * value -- An initial value to be assigned to attribute.
torch.asinh
torch.asinh(input, *, out=None) -> Tensor
Returns a new tensor with the inverse hyperbolic sine of the
   elements of "input".
  \text{out}_{i} = \sinh^{-1}(\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.1606, -1.4267, -1.0899, -1.0250 ])
  >>> torch.asinh(a)
  tensor([ 0.1599, -1.1534, -0.9435, -0.8990 ])
torch.signal.windows.kaiser
torch.signal.windows.kaiser(M, *, beta=12.0, sym=True, dtype=None, layout=torch.strided, device=None, requires_grad=False)
Computes the Kaiser window.
The Kaiser window is defined as follows:
  w_n = I_0 \left( \beta \sqrt{1 - \left( {\frac{n - N/2}{N/2}}
  \right) ^2 } \right) / I_0( \beta )

where "I_0" is the zeroth order modified Bessel function of the
   first kind (see "torch.special.i0()"), and "N = M - 1 if sym else
   M".
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:
      * beta (float, optional) -- shape parameter for the
        window. Must be non-negative. Default: 12.0
  * **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.
  * **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:
Return type:
      Tensor
Examples:
  >>> # Generates a symmetric gaussian window with a standard deviation of 1.0.
  >>> torch.signal.windows.kaiser(5)
  tensor([4.0065e-05, 2.1875e-03, 4.3937e-02, 3.2465e-01, 8.8250e-01, 8.8250e-01, 3.2465e-01, 4.3937e-02, 2.1875e-03, 4.0065e-05])
  >>> # Generates a periodic gaussian window and standard deviation equal to 0.9.
  >>> torch.signal.windows.kaiser(5, sym=False,std=0.9)
  tensor([1.9858e-07, 5.1365e-05, 3.8659e-03, 8.4658e-02, 5.3941e-01, 1.0000e+00, 5.3941e-01, 8.4658e-02, 3.8659e-03, 5.1365e-05])
torch.linalg.cross
torch.linalg.cross(input, other, *, dim=- 1, out=None) -> Tensor
Computes the cross product of two 3-dimensional vectors.
Supports input of float, double, cfloat and cdouble dtypes. Also
   supports batches of vectors, for which it computes the product
   along the dimension "dim". It broadcasts over the batch dimensions.
Parameters:
      * input (Tensor) -- the first input tensor.
  * **other** (*Tensor*) -- the second input tensor.

  * **dim** (*int**, **optional*) -- the dimension along which to
    take the cross-product. Default: *-1*.

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



a = torch.randn(4, 3)
a
   tensor([[-0.3956,  1.1455,  1.6895],
           [-0.5849,  1.3672,  0.3599],
           [-1.1626,  0.7180, -0.0521],
           [-0.1339,  0.9902, -2.0225]])
b = torch.randn(4, 3)
b
b = torch.randn(4, 3)
b
   tensor([[-0.0257, -1.4725, -1.2251],
           [-1.1479, -0.7005, -1.9757],
           [-1.3904,  0.3726, -1.1836],
           [-0.9688, -0.7153,  0.2159]])
torch.linalg.cross(a, b)
   tensor([[ 1.0844, -0.5281,  0.6120],
           [-2.4490, -1.5687,  1.9792],
           [-0.8304, -1.3037,  0.5650],
           [-1.2329,  1.9883,  1.0551]])
a = torch.randn(1, 3)  # a is broadcast to match shape of b
a
   tensor([[-0.9941, -0.5132,  0.5681]])
torch.linalg.cross(a, b)
   tensor([[ 1.4653, -1.2325,  1.4507],
           [ 1.4119, -2.6163,  0.1073],
           [ 0.3957, -1.9666, -1.0840],
           [ 0.2956, -0.3357,  0.2139]])
torch.combinations
torch.combinations(input, r=2, with_replacement=False) -> seq
Compute combinations of length r of the given tensor. The behavior
   is similar to python's itertools.combinations when
   with_replacement is set to False, and
   itertools.combinations_with_replacement when with_replacement
   is set to True.
Parameters:
      * input (Tensor) -- 1D vector.
  * **r** (*int**, **optional*) -- number of elements to combine

  * **with_replacement** (*bool**, **optional*) -- whether to
    allow duplication in combination

Returns:
      A tensor equivalent to converting all the input tensors into
      lists, do itertools.combinations or
      itertools.combinations_with_replacement on these lists, and
      finally convert the resulting list into tensor.
Return type:
      Tensor
Example:
  >>> a = [1, 2, 3]
  >>> list(itertools.combinations(a, r=2))
  [(1, 2), (1, 3), (2, 3)]
[(1, 2), (1, 3), (2, 3)]
      >>> list(itertools.combinations(a, r=3))
      [(1, 2, 3)]
      >>> list(itertools.combinations_with_replacement(a, r=2))
      [(1, 1), (1, 2), (1, 3), (2, 2), (2, 3), (3, 3)]
      >>> tensor_a = torch.tensor(a)
      >>> torch.combinations(tensor_a)
      tensor([[1, 2],
              [1, 3],
              [2, 3]])
      >>> torch.combinations(tensor_a, r=3)
      tensor([[1, 2, 3]])
      >>> torch.combinations(tensor_a, with_replacement=True)
      tensor([[1, 1],
              [1, 2],
              [1, 3],
              [2, 2],
              [2, 3],
              [3, 3]])
Unfold
class torch.nn.Unfold(kernel_size, dilation=1, padding=0, stride=1)
Extracts sliding local blocks from a batched input tensor.
Consider a batched "input" tensor of shape (N, C, *), where N is
   the batch dimension, C is the channel dimension, and * represent
   arbitrary spatial dimensions. This operation flattens each sliding
   "kernel_size"-sized block within the spatial dimensions of "input"
   into a column (i.e., last dimension) of a 3-D "output" tensor of
   shape (N, C \times \prod(\text{kernel_size}), L), where C \times
   \prod(\text{kernel_size}) is the total number of values within
   each block (a block has \prod(\text{kernel_size}) spatial
   locations each containing a C-channeled vector), and L is the total
   number of such blocks:
  L = \prod_d \left\lfloor\frac{\text{spatial\_size}[d] + 2 \times
  \text{padding}[d] %     - \text{dilation}[d] \times
  (\text{kernel\_size}[d] - 1) - 1}{\text{stride}[d]} +
  1\right\rfloor,
1\right\rfloor,
where \text{spatial_size} is formed by the spatial dimensions of
   "input" (* above), and d is over all spatial dimensions.
Therefore, indexing "output" at the last dimension (column
   dimension) gives all values within a certain block.
The "padding", "stride" and "dilation" arguments specify how the
   sliding blocks are retrieved.


"stride" controls the stride for the sliding blocks.


"padding" controls the amount of implicit zero-paddings on both
     sides for "padding" number of points for each dimension before
     reshaping.


"dilation" controls the spacing between the kernel points; also
     known as the Ã  trous algorithm. It is harder to describe, but
     this link has a nice visualization of what "dilation" does.


Parameters:
      * kernel_size (int or tuple) -- the size of the
        sliding blocks
  * **dilation** (*int** or **tuple**, **optional*) -- a parameter
that controls the stride of elements within the neighborhood.
        Default: 1
  * **padding** (*int** or **tuple**, **optional*) -- implicit
    zero padding to be added on both sides of input. Default: 0

  * **stride** (*int** or **tuple**, **optional*) -- the stride of
    the sliding blocks in the input spatial dimensions. Default: 1



If "kernel_size", "dilation", "padding" or "stride" is an int or
     a tuple of length 1, their values will be replicated across all
     spatial dimensions.


For the case of two input spatial dimensions this operation is
     sometimes called "im2col".


Note:
 "Fold" calculates each combined value in the resulting large
 tensor by summing all values from all containing blocks. "Unfold"
 extracts the values in the local blocks by copying from the large
 tensor. So, if the blocks overlap, they are not inverses of each
 other.In general, folding and unfolding operations are related as
follows. Consider "Fold" and "Unfold" instances created with the
     same parameters:
 >>> fold_params = dict(kernel_size=..., dilation=..., padding=..., stride=...)
 >>> fold = nn.Fold(output_size=..., **fold_params)
 >>> unfold = nn.Unfold(**fold_params)

 Then for any (supported) "input" tensor the following equality
 holds:

    fold(unfold(input)) == divisor * input

 where "divisor" is a tensor that depends only on the shape and
 dtype of the "input":

 >>> input_ones = torch.ones(input.shape, dtype=input.dtype)
 >>> divisor = fold(unfold(input_ones))

 When the "divisor" tensor contains no zero elements, then "fold"
 and "unfold" operations are inverses of each other (up to
 constant divisor).

Warning:
 Currently, only 4-D input tensors (batched image-like tensors)
 are supported.

Shape:
      * Input: (N, C, *)
  * Output: (N, C \times \prod(\text{kernel\_size}), L) as
    described above

Examples:
described above
Examples:
  >>> unfold = nn.Unfold(kernel_size=(2, 3))
  >>> input = torch.randn(2, 5, 3, 4)
  >>> output = unfold(input)
  >>> # each patch contains 30 values (2x3=6 vectors, each of 5 channels)
  >>> # 4 blocks (2x3 kernels) in total in the 3x4 input
  >>> output.size()
  torch.Size([2, 30, 4])

  >>> # Convolution is equivalent with Unfold + Matrix Multiplication + Fold (or view to output shape)
  >>> inp = torch.randn(1, 3, 10, 12)
  >>> w = torch.randn(2, 3, 4, 5)
  >>> inp_unf = torch.nn.functional.unfold(inp, (4, 5))
  >>> out_unf = inp_unf.transpose(1, 2).matmul(w.view(w.size(0), -1).t()).transpose(1, 2)
  >>> out = torch.nn.functional.fold(out_unf, (7, 8), (1, 1))
  >>> # or equivalently (and avoiding a copy),
  >>> # out = out_unf.view(1, 2, 7, 8)
  >>> (torch.nn.functional.conv2d(inp, w) - out).abs().max()
  tensor(1.9073e-06)
torch.unique_consecutive
torch.unique_consecutive(args, *kwargs)
Eliminates all but the first element from every consecutive group
   of equivalent elements.
Note:
 This function is different from "torch.unique()" in the sense
 that this function only eliminates consecutive duplicate values.
 This semantics is similar to *std::unique* in C++.

Parameters:
      * input (Tensor) -- the input tensor
  * **return_inverse** (*bool*) -- Whether to also return the
    indices for where elements in the original input ended up in
    the returned unique list.

  * **return_counts** (*bool*) -- Whether to also return the
    counts for each unique element.

  * **dim** (*int*) -- the dimension to apply unique. If "None",
    the unique of the flattened input is returned. default: "None"

Returns:
      A tensor or a tuple of tensors containing
     * **output** (*Tensor*): the output list of unique scalar
elements.
     * **inverse_indices** (*Tensor*): (optional) if
       "return_inverse" is True, there will be an additional
       returned tensor (same shape as input) representing the
       indices for where elements in the original input map to in
       the output; otherwise, this function will only return a
       single tensor.

     * **counts** (*Tensor*): (optional) if "return_counts" is
       True, there will be an additional returned tensor (same
       shape as output or output.size(dim), if dim was specified)
       representing the number of occurrences for each unique
       value or tensor.

Return type:
      (Tensor, Tensor (optional), Tensor (optional))
Example:
  >>> x = torch.tensor([1, 1, 2, 2, 3, 1, 1, 2])
  >>> output = torch.unique_consecutive(x)
  >>> output
  tensor([1, 2, 3, 1, 2])

  >>> output, inverse_indices = torch.unique_consecutive(x, return_inverse=True)
  >>> output
output
      tensor([1, 2, 3, 1, 2])
      >>> inverse_indices
      tensor([0, 0, 1, 1, 2, 3, 3, 4])



  >>> output, counts = torch.unique_consecutive(x, return_counts=True)
  >>> output
  tensor([1, 2, 3, 1, 2])
  >>> counts
  tensor([2, 2, 1, 2, 1])
torch.trace
torch.trace(input) -> Tensor
Returns the sum of the elements of the diagonal of the input 2-D
   matrix.
Example:
  >>> x = torch.arange(1., 10.).view(3, 3)
  >>> x
  tensor([[ 1.,  2.,  3.],
          [ 4.,  5.,  6.],
          [ 7.,  8.,  9.]])
  >>> torch.trace(x)
  tensor(15.)
SoftMarginLoss
class torch.nn.SoftMarginLoss(size_average=None, reduce=None, reduction='mean')
Creates a criterion that optimizes a two-class classification
   logistic loss between input tensor x and target tensor y
   (containing 1 or -1).
  \text{loss}(x, y) = \sum_i \frac{\log(1 +
  \exp(-y[i]*x[i]))}{\text{x.nelement}()}

Parameters:
      * size_average (bool, optional) -- Deprecated (see
        "reduction"). By default, the losses are averaged over each
        loss element in the batch. Note that for some losses, there
        are multiple elements per sample. If the field "size_average"
        is set to "False", the losses are instead summed for each
        minibatch. Ignored when "reduce" is "False". Default: "True"
  * **reduce** (*bool**, **optional*) -- Deprecated (see
    "reduction"). By default, the losses are averaged or summed
    over observations for each minibatch depending on
"size_average". When "reduce" is "False", returns a loss per
        batch element instead and ignores "size_average". Default:
        "True"
  * **reduction** (*str**, **optional*) -- Specifies the reduction
    to apply to the output: "'none'" | "'mean'" | "'sum'".
    "'none'": no reduction will be applied, "'mean'": the sum of
    the output will be divided by the number of elements in the
    output, "'sum'": the output will be summed. Note:
    "size_average" and "reduce" are in the process of being
    deprecated, and in the meantime, specifying either of those
    two args will override "reduction". Default: "'mean'"

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

  * Output: scalar. If "reduction" is "'none'", then (*), same
    shape as input.
get_default_qat_qconfig_mapping
class torch.ao.quantization.qconfig_mapping.get_default_qat_qconfig_mapping(backend='x86', version=1)
Return the default QConfigMapping for quantization aware training.
Parameters:
      * backend (***) -- the quantization backend for the default
        qconfig mapping, should be one of ["x86" (default), "fbgemm",
        "qnnpack", "onednn"]
  * **version** (***) -- the version for the default qconfig
    mapping

Return type:
      QConfigMapping
torch.Tensor.to_sparse_bsr
Tensor.to_sparse_bsr(blocksize, dense_dim) -> Tensor
Convert a tensor to a block sparse row (BSR) storage format of
   given blocksize.  If the "self" is strided, then the number of
   dense dimensions could be specified, and a hybrid BSR tensor will
   be created, with dense_dim dense dimensions and self.dim() - 2 -
   dense_dim batch dimension.
Parameters:
      * blocksize (list, tuple, "torch.Size", optional) -- Block
        size of the resulting BSR tensor. A block size must be a tuple
        of length two such that its items evenly divide the two sparse
        dimensions.
  * **dense_dim** (*int**, **optional*) -- Number of dense
    dimensions of the resulting BSR tensor.  This argument should
    be used only if "self" is a strided tensor, and must be a
    value between 0 and dimension of "self" tensor minus two.

Example:
  >>> dense = torch.randn(10, 10)
  >>> sparse = dense.to_sparse_csr()
sparse = dense.to_sparse_csr()
      >>> sparse_bsr = sparse.to_sparse_bsr((5, 5))
      >>> sparse_bsr.col_indices()
      tensor([0, 1, 0, 1])



  >>> dense = torch.zeros(4, 3, 1)
  >>> dense[0:2, 0] = dense[0:2, 2] = dense[2:4, 1] = 1
  >>> dense.to_sparse_bsr((2, 1), 1)
  tensor(crow_indices=tensor([0, 2, 3]),
         col_indices=tensor([0, 2, 1]),
         values=tensor([[[[1.]],

                         [[1.]]],


                        [[[1.]],

                         [[1.]]],


                        [[[1.]],

                         [[1.]]]]), size=(4, 3, 1), nnz=3,
         layout=torch.sparse_bsr)
torch.index_select
torch.index_select(input, dim, index, *, out=None) -> Tensor
Returns a new tensor which indexes the "input" tensor along
   dimension "dim" using the entries in "index" which is a
   LongTensor.
The returned tensor has the same number of dimensions as the
   original tensor ("input").  The "dim"th dimension has the same size
   as the length of "index"; other dimensions have the same size as in
   the original tensor.
Note:
 The returned tensor does **not** use the same storage as the
 original tensor.  If "out" has a different shape than expected,
 we silently change it to the correct shape, reallocating the
 underlying storage if necessary.

Parameters:
      * input (Tensor) -- the input tensor.
  * **dim** (*int*) -- the dimension in which we index

  * **index** (*IntTensor** or **LongTensor*) -- the 1-D tensor
    containing the indices to index

Keyword Arguments:
Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> x = torch.randn(3, 4)
  >>> x
  tensor([[ 0.1427,  0.0231, -0.5414, -1.0009],
          [-0.4664,  0.2647, -0.1228, -1.1068],
          [-1.1734, -0.6571,  0.7230, -0.6004]])
  >>> indices = torch.tensor([0, 2])
  >>> torch.index_select(x, 0, indices)
  tensor([[ 0.1427,  0.0231, -0.5414, -1.0009],
          [-1.1734, -0.6571,  0.7230, -0.6004]])
  >>> torch.index_select(x, 1, indices)
  tensor([[ 0.1427, -0.5414],
          [-0.4664, -0.1228],
          [-1.1734,  0.7230]])