shrinath-suresh/blogs-docs-splitted huggingface dataset:
torch.heaviside
torch.heaviside(input, values, *, out=None) -> Tensor
Computes the Heaviside step function for each element in "input".
   The Heaviside step function is defined as:
  \text{{heaviside}}(input, values) = \begin{cases}     0, &
  \text{if input < 0}\\     values, & \text{if input == 0}\\
  1, & \text{if input > 0} \end{cases}

Parameters:
      * input (Tensor) -- the input tensor.
  * **values** (*Tensor*) -- The values to use where "input" is
    zero.

Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> input = torch.tensor([-1.5, 0, 2.0])
  >>> values = torch.tensor([0.5])
  >>> torch.heaviside(input, values)
  tensor([0.0000, 0.5000, 1.0000])
  >>> values = torch.tensor([1.2, -2.0, 3.5])
  >>> torch.heaviside(input, values)
  tensor([0., -2., 1.])
torch.cuda.get_allocator_backend
torch.cuda.get_allocator_backend()
Returns a string describing the active allocator backend as set by
   "PYTORCH_CUDA_ALLOC_CONF". Currently available backends are
   "native" (PyTorch's native caching allocator) and
   cudaMallocAsync` (CUDA's built-in asynchronous allocator).
Note:
 See Memory management for details on choosing the allocator
 backend.

Return type:
      str
torch.nn.functional.upsample
torch.nn.functional.upsample(input, size=None, scale_factor=None, mode='nearest', align_corners=None)
Upsamples the input to either the given "size" or the given
   "scale_factor"
Warning:
 This function is deprecated in favor of
 "torch.nn.functional.interpolate()". This is equivalent with
 "nn.functional.interpolate(...)".

Note:
 This operation may produce nondeterministic gradients when given
 tensors on a CUDA device. See Reproducibility for more
 information.

The algorithm used for upsampling is determined by "mode".
Currently temporal, spatial and volumetric upsampling are
   supported, i.e. expected inputs are 3-D, 4-D or 5-D in shape.
The input dimensions are interpreted in the form: mini-batch x
   channels x [optional depth] x [optional height] x width.
The modes available for upsampling are: nearest, linear (3D-
   only), bilinear, bicubic (4D-only), trilinear (5D-only)
Parameters:
      * input (Tensor) -- the input tensor
  * **size** (*int** or **Tuple**[**int**] or **Tuple**[**int**,
    **int**] or **Tuple**[**int**, **int**, **int**]*) -- output
    spatial size.

  * **scale_factor** (*float** or **Tuple**[**float**]*) --
    multiplier for spatial size. Has to match input size if it is
    a tuple.

  * **mode** (*str*) -- algorithm used for upsampling: "'nearest'"
    | "'linear'" | "'bilinear'" | "'bicubic'" | "'trilinear'".
    Default: "'nearest'"

  * **align_corners** (*bool**, **optional*) -- Geometrically, we
    consider the pixels of the input and output as squares rather
    than points. If set to "True", the input and output tensors
    are aligned by the center points of their corner pixels,
    preserving the values at the corner pixels. If set to "False",
    the input and output tensors are aligned by the corner points
of their corner pixels, and the interpolation uses edge value
        padding for out-of-boundary values, making this operation
        independent of input size when "scale_factor" is kept the
        same. This only has an effect when "mode" is "'linear'",
        "'bilinear'", "'bicubic'" or "'trilinear'". Default: "False"
Note:
 With "mode='bicubic'", it's possible to cause overshoot, in other
 words it can produce negative values or values greater than 255
 for images. Explicitly call "result.clamp(min=0, max=255)" if you
 want to reduce the overshoot when displaying the image.

Warning:
 With "align_corners = True", the linearly interpolating modes
 (*linear*, *bilinear*, and *trilinear*) don't proportionally
 align the output and input pixels, and thus the output values can
 depend on the input size. This was the default behavior for these
 modes up to version 0.3.1. Since then, the default behavior is
torch.linalg.vecdot
torch.linalg.vecdot(x, y, *, dim=- 1, out=None) -> Tensor
Computes the dot product of two batches of vectors along a
   dimension.
In symbols, this function computes
  \sum_{i=1}^n \overline{x_i}y_i.

over the dimension "dim" where \overline{x_i} denotes the conjugate
   for complex vectors, and it is the identity for real vectors.
Supports input of half, bfloat16, float, double, cfloat, cdouble
   and integral dtypes. It also supports broadcasting.
Parameters:
      * x (Tensor) -- first batch of vectors of shape (, n)*.
  * **y** (*Tensor*) -- second batch of vectors of shape *(*, n)*.

Keyword Arguments:
      * dim (int) -- Dimension along which to compute the dot
        product. Default: -1.
  * **out** (*Tensor**, **optional*) -- output tensor. Ignored if
    *None*. Default: *None*.

Examples:
  >>> v1 = torch.randn(3, 2)
  >>> v2 = torch.randn(3, 2)
  >>> linalg.vecdot(v1, v2)
torch.Tensor.stride
Tensor.stride(dim) -> tuple or int
Returns the stride of "self" tensor.
Stride is the jump necessary to go from one element to the next one
   in the specified dimension "dim". A tuple of all strides is
   returned when no argument is passed in. Otherwise, an integer value
   is returned as the stride in the particular dimension "dim".
Parameters:
      dim (int, optional) -- the desired dimension in which
      stride is required
Example:
  >>> x = torch.tensor([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
  >>> x.stride()
  (5, 1)
  >>> x.stride(0)
  5
  >>> x.stride(-1)
  1
ReplicationPad1d
class torch.nn.ReplicationPad1d(padding)
Pads the input tensor using replication of the input boundary.
For N-dimensional padding, use "torch.nn.functional.pad()".
Parameters:
      padding (int, tuple) -- the size of the padding. If is
      int, uses the same padding in all boundaries. If a 2-tuple,
      uses (\text{padding_left}, \text{padding_right})
Shape:
      * Input: (C, W_{in}) or (N, C, W_{in}).
  * Output: (C, W_{out}) or (N, C, W_{out}), where

    W_{out} = W_{in} + \text{padding\_left} +
    \text{padding\_right}

Examples:
  >>> m = nn.ReplicationPad1d(2)
  >>> input = torch.arange(8, dtype=torch.float).reshape(1, 2, 4)
  >>> input
  tensor([[[0., 1., 2., 3.],
           [4., 5., 6., 7.]]])
  >>> m(input)
  tensor([[[0., 0., 0., 1., 2., 3., 3., 3.],
           [4., 4., 4., 5., 6., 7., 7., 7.]]])
  >>> # using different paddings for different sides
torch.linalg.qr
torch.linalg.qr(A, mode='reduced', *, out=None)
Computes the QR decomposition of a matrix.
Letting \mathbb{K} be \mathbb{R} or \mathbb{C}, the full QR
   decomposition of a matrix A \in \mathbb{K}^{m \times n} is
   defined as
  A = QR\mathrlap{\qquad Q \in \mathbb{K}^{m \times m}, R \in
  \mathbb{K}^{m \times n}}

where Q is orthogonal in the real case and unitary in the complex
   case, and R is upper triangular with real diagonal (even in the
   complex case).
When m > n (tall matrix), as R is upper triangular, its last m
   - n rows are zero. In this case, we can drop the last m - n
   columns of Q to form the reduced QR decomposition:
  A = QR\mathrlap{\qquad Q \in \mathbb{K}^{m \times n}, R \in
  \mathbb{K}^{n \times n}}

The reduced QR decomposition agrees with the full QR decomposition
   when n >= m (wide matrix).
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.
The parameter "mode" chooses between the full and reduced QR
   decomposition. If "A" has shape (, m, n), denoting k = min(m,
   n)*


"mode"= 'reduced' (default): Returns (Q, R) of shapes (, m,
     k), (, k, n) respectively. It is always differentiable.


"mode"= 'complete': Returns (Q, R) of shapes (, m, m),
     (, m, n) respectively. It is differentiable for m <= n.


"mode"= 'r': Computes only the reduced R. Returns (Q, R)
     with Q empty and R of shape (, k, n)*. It is never
     differentiable.


Differences with numpy.linalg.qr:


"mode"= 'raw' is not implemented.


Unlike numpy.linalg.qr, this function always returns a tuple of
     two tensors. When "mode"= 'r', the Q tensor is an empty
     tensor.


Warning:
 The elements in the diagonal of *R* are not necessarily positive.
As such, the returned QR decomposition is only unique up to the
     sign of the diagonal of R. Therefore, different platforms, like
     NumPy, or inputs on different devices, may produce different
     valid decompositions.
Warning:
 The QR decomposition is only well-defined if the first *k =
 min(m, n)* columns of every matrix in "A" are linearly
 independent. If this condition is not met, no error will be
 thrown, but the QR produced may be incorrect and its autodiff may
 fail or produce incorrect results.

Parameters:
      * A (Tensor) -- tensor of shape (, m, n)* where *** is
        zero or more batch dimensions.
  * **mode** (*str**, **optional*) -- one of *'reduced'*,
    *'complete'*, *'r'*. Controls the shape of the returned
    tensors. Default: *'reduced'*.

Keyword Arguments:
      out (tuple, optional) -- output tuple of two tensors.
      Ignored if None. Default: None.
Returns:
      A named tuple (Q, R).
Returns:
      A named tuple (Q, R).
Examples:
  >>> A = torch.tensor([[12., -51, 4], [6, 167, -68], [-4, 24, -41]])
  >>> Q, R = torch.linalg.qr(A)
  >>> Q
  tensor([[-0.8571,  0.3943,  0.3314],
          [-0.4286, -0.9029, -0.0343],
          [ 0.2857, -0.1714,  0.9429]])
  >>> R
  tensor([[ -14.0000,  -21.0000,   14.0000],
          [   0.0000, -175.0000,   70.0000],
          [   0.0000,    0.0000,  -35.0000]])
  >>> (Q @ R).round()
  tensor([[  12.,  -51.,    4.],
          [   6.,  167.,  -68.],
          [  -4.,   24.,  -41.]])
  >>> (Q.T @ Q).round()
  tensor([[ 1.,  0.,  0.],
          [ 0.,  1., -0.],
          [ 0., -0.,  1.]])
  >>> Q2, R2 = torch.linalg.qr(A, mode='r')
  >>> Q2
  tensor([])
  >>> torch.equal(R, R2)
  True
  >>> A = torch.randn(3, 4, 5)
  >>> Q, R = torch.linalg.qr(A, mode='complete')
  >>> torch.dist(Q @ R, A)
  tensor(1.6099e-06)
torch.cuda.get_device_capability
torch.cuda.get_device_capability(device=None)
Gets the cuda capability of a device.
Parameters:
      device (torch.device or int, optional) -- device
      for which to return the device capability. This function is a
      no-op if this argument is a negative integer. It uses the
      current device, given by "current_device()", if "device" is
      "None" (default).
Returns:
      the major and minor cuda capability of the device
Return type:
      tuple(int, int)
CosineAnnealingLR
class torch.optim.lr_scheduler.CosineAnnealingLR(optimizer, T_max, eta_min=0, last_epoch=- 1, verbose=False)
Set the learning rate of each parameter group using a cosine
   annealing schedule, where \eta_{max} is set to the initial lr and
   T_{cur} is the number of epochs since the last restart in SGDR:
  \begin{aligned}     \eta_t & = \eta_{min} +
  \frac{1}{2}(\eta_{max} - \eta_{min})\left(1     +
  \cos\left(\frac{T_{cur}}{T_{max}}\pi\right)\right),     &
  T_{cur} \neq (2k+1)T_{max}; \\     \eta_{t+1} & = \eta_{t} +
  \frac{1}{2}(\eta_{max} - \eta_{min})     \left(1 -
  \cos\left(\frac{1}{T_{max}}\pi\right)\right),     & T_{cur} =
  (2k+1)T_{max}. \end{aligned}

When last_epoch=-1, sets initial lr as lr. Notice that because the
   schedule is defined recursively, the learning rate can be
   simultaneously modified outside this scheduler by other operators.
   If the learning rate is set solely by this scheduler, the learning
rate at each step becomes:
  \eta_t = \eta_{min} + \frac{1}{2}(\eta_{max} -
  \eta_{min})\left(1 +
  \cos\left(\frac{T_{cur}}{T_{max}}\pi\right)\right)

It has been proposed in SGDR: Stochastic Gradient Descent with Warm
   Restarts. Note that this only implements the cosine annealing part
   of SGDR, and not the restarts.
Parameters:
      * optimizer (Optimizer) -- Wrapped optimizer.
  * **T_max** (*int*) -- Maximum number of iterations.

  * **eta_min** (*float*) -- Minimum learning rate. Default: 0.

  * **last_epoch** (*int*) -- The index of last epoch. Default:
    -1.

  * **verbose** (*bool*) -- If "True", prints a message to stdout
    for each update. Default: "False".

get_last_lr()
  Return last computed learning rate by current scheduler.

load_state_dict(state_dict)
  Loads the schedulers state.

  Parameters:
     **state_dict** (*dict*) -- scheduler state. Should be an
Conv1d
class torch.ao.nn.quantized.Conv1d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros', device=None, dtype=None)
Applies a 1D convolution over a quantized input signal composed of
   several quantized input planes.
For details on input arguments, parameters, and implementation see
   "Conv1d".
Note:
 Only *zeros* is supported for the "padding_mode" argument.

Note:
 Only *torch.quint8* is supported for the input data type.

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 "Conv1d" for other attributes.
Examples:
  >>> m = nn.quantized.Conv1d(16, 33, 3, stride=2)
  >>> input = torch.randn(20, 16, 100)
  >>> # quantize input to quint8
quantize input to quint8
  >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0,
  ...                                     dtype=torch.quint8)
  >>> output = m(q_input)




classmethod from_float(mod)
  Creates a quantized module from a float module or qparams_dict.

  Parameters:
     **mod** (*Module*) -- a float module, either produced by
     torch.ao.quantization utilities or provided by the user
DTypeConfig
class torch.ao.quantization.backend_config.DTypeConfig(input_dtype=None, output_dtype=None, weight_dtype=None, bias_dtype=None, is_dynamic=None)
Config object that specifies the supported data types passed as
   arguments to quantize ops in the reference model spec, for input
   and output activations, weights, and biases.
For example, consider the following reference model:
  quant1 - [dequant1 - fp32_linear - quant2] - dequant2

The pattern in the square brackets refers to the reference pattern
   of statically quantized linear. Setting the input dtype as
   torch.quint8 in the DTypeConfig means we pass in torch.quint8
   as the dtype argument to the first quantize op (quant1). Similarly,
   setting the output dtype as torch.quint8 means we pass in
   torch.quint8 as the dtype argument to the second quantize op
   (quant2).
Note that the dtype here does not refer to the interface dtypes of
the op. For example, the "input dtype" here is not the dtype of the
   input tensor passed to the quantized linear op. Though it can still
   be the same as the interface dtype, this is not always the case,
   e.g. the interface dtype is fp32 in dynamic quantization but the
   "input dtype" specified in the DTypeConfig would still be quint8.
   The semantics of dtypes here are the same as the semantics of the
   dtypes specified in the observers.
These dtypes are matched against the ones specified in the userâs
   QConfig. If there is a match, and the QConfig satisfies the
   constraints specified in the DTypeConfig (if any), then we will
   quantize the given pattern using this DTypeConfig. Otherwise, the
   QConfig is ignored and the pattern will not be quantized.
Example usage:
  >>> dtype_config1 = DTypeConfig(
  ...     input_dtype=torch.quint8,
  ...     output_dtype=torch.quint8,
  ...     weight_dtype=torch.qint8,
  ...     bias_dtype=torch.float)
...     bias_dtype=torch.float)
  >>> dtype_config2 = DTypeConfig(
  ...     input_dtype=DTypeWithConstraints(
  ...         dtype=torch.quint8,
  ...         quant_min_lower_bound=0,
  ...         quant_max_upper_bound=255,
  ...     ),
  ...     output_dtype=DTypeWithConstraints(
  ...         dtype=torch.quint8,
  ...         quant_min_lower_bound=0,
  ...         quant_max_upper_bound=255,
  ...     ),
  ...     weight_dtype=DTypeWithConstraints(
  ...         dtype=torch.qint8,
  ...         quant_min_lower_bound=-128,
  ...         quant_max_upper_bound=127,
  ...     ),
  ...     bias_dtype=torch.float)

  >>> dtype_config1.input_dtype
  torch.quint8

  >>> dtype_config2.input_dtype
  torch.quint8

  >>> dtype_config2.input_dtype_with_constraints
  DTypeWithConstraints(dtype=torch.quint8, quant_min_lower_bound=0, quant_max_upper_bound=255, scale_min_lower_bound=None, scale_max_upper_bound=None)
classmethod from_dict(dtype_config_dict)
  Create a "DTypeConfig" from a dictionary with the following
  items (all optional):
     "input_dtype": torch.dtype or "DTypeWithConstraints"
     "output_dtype": torch.dtype or "DTypeWithConstraints"
     "weight_dtype": torch.dtype or "DTypeWithConstraints"
     "bias_type": torch.dtype "is_dynamic": bool

  Return type:
     *DTypeConfig*

to_dict()
  Convert this "DTypeConfig" to a dictionary with the items
  described in "from_dict()".

  Return type:
     *Dict*[str, *Any*]
BCEWithLogitsLoss
class torch.nn.BCEWithLogitsLoss(weight=None, size_average=None, reduce=None, reduction='mean', pos_weight=None)
This loss combines a Sigmoid layer and the BCELoss in one
   single class. This version is more numerically stable than using a
   plain Sigmoid followed by a BCELoss as, by combining the
   operations into one layer, we take advantage of the log-sum-exp
   trick for numerical stability.
The unreduced (i.e. with "reduction" set to "'none'") loss can be
   described as:
  \ell(x, y) = L = \{l_1,\dots,l_N\}^\top, \quad l_n = - w_n
  \left[ y_n \cdot \log \sigma(x_n) + (1 - y_n) \cdot \log (1 -
  \sigma(x_n)) \right],

where N is the batch size. If "reduction" is not "'none'" (default
   "'mean'"), then
  \ell(x, y) = \begin{cases}     \operatorname{mean}(L), &
  \text{if reduction} = \text{`mean';}\\
  \operatorname{sum}(L),  & \text{if reduction} = \text{`sum'.}
  \end{cases}
\end{cases}
This is used for measuring the error of a reconstruction in for
   example an auto-encoder. Note that the targets t[i] should be
   numbers between 0 and 1.
It's possible to trade off recall and precision by adding weights
   to positive examples. In the case of multi-label classification the
   loss can be described as:
  \ell_c(x, y) = L_c = \{l_{1,c},\dots,l_{N,c}\}^\top, \quad
  l_{n,c} = - w_{n,c} \left[ p_c y_{n,c} \cdot \log
  \sigma(x_{n,c}) + (1 - y_{n,c}) \cdot \log (1 - \sigma(x_{n,c}))
  \right],

where c is the class number (c > 1 for multi-label binary
   classification, c = 1 for single-label binary classification), n is
   the number of the sample in the batch and p_c is the weight of the
   positive answer for the class c.
p_c > 1 increases the recall, p_c < 1 increases the precision.
For example, if a dataset contains 100 positive and 300 negative
   examples of a single class, then pos_weight for the class should
be equal to \frac{300}{100}=3. The loss would act as if the dataset
   contains 3\times 100=300 positive examples.
Examples:
  >>> target = torch.ones([10, 64], dtype=torch.float32)  # 64 classes, batch size = 10
  >>> output = torch.full([10, 64], 1.5)  # A prediction (logit)
  >>> pos_weight = torch.ones([64])  # All weights are equal to 1
  >>> criterion = torch.nn.BCEWithLogitsLoss(pos_weight=pos_weight)
  >>> criterion(output, target)  # -log(sigmoid(1.5))
  tensor(0.20...)

Parameters:
      * weight (Tensor, optional) -- a manual rescaling
        weight given to the loss of each batch element. If given, has
        to be a Tensor of size nbatch.
  * **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'"
pos_weight (Tensor, optional) -- a weight of
        positive examples. Must be a vector with length equal to the
        number of classes.

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.

  Examples:

     >>> loss = nn.BCEWithLogitsLoss()
     >>> input = torch.randn(3, requires_grad=True)
     >>> target = torch.empty(3).random_(2)
     >>> output = loss(input, target)
     >>> output.backward()
torch.autograd.gradcheck
torch.autograd.gradcheck(func, inputs, *, eps=1e-06, atol=1e-05, rtol=0.001, raise_exception=True, check_sparse_nnz=False, nondet_tol=0.0, check_undefined_grad=True, check_grad_dtypes=False, check_batched_grad=False, check_batched_forward_grad=False, check_forward_ad=False, check_backward_ad=True, fast_mode=False)
Check gradients computed via small finite differences against
   analytical gradients w.r.t. tensors in "inputs" that are of
   floating point or complex type and with "requires_grad=True".
The check between numerical and analytical gradients uses
   "allclose()".
For most of the complex functions we consider for optimization
   purposes, no notion of Jacobian exists. Instead, gradcheck verifies
   if the numerical and analytical values of the Wirtinger and
   Conjugate Wirtinger derivatives are consistent. Because the
   gradient computation is done under the assumption that the overall
function has a real-valued output, we treat functions with complex
   output in a special way. For these functions, gradcheck is applied
   to two real-valued functions corresponding to taking the real
   components of the complex outputs for the first, and taking the
   imaginary components of the complex outputs for the second. For
   more details, check out Autograd for Complex Numbers.
Note:
 The default values are designed for "input" of double precision.
 This check will likely fail if "input" is of less precision,
 e.g., "FloatTensor".

Warning:
 If any checked tensor in "input" has overlapping memory, i.e.,
 different indices pointing to the same memory address (e.g., from
 "torch.expand()"), this check will likely fail because the
 numerical gradients computed by point perturbation at such
 indices will change values at all other indices that share the
 same memory address.

Parameters:
same memory address.
Parameters:
      * func (function) -- a Python function that takes Tensor
        inputs and returns a Tensor or a tuple of Tensors
  * **inputs** (*tuple of Tensor** or **Tensor*) -- inputs to the
    function

  * **eps** (*float**, **optional*) -- perturbation for finite
    differences

  * **atol** (*float**, **optional*) -- absolute tolerance

  * **rtol** (*float**, **optional*) -- relative tolerance

  * **raise_exception** (*bool**, **optional*) -- indicating
    whether to raise an exception if the check fails. The
    exception gives more information about the exact nature of the
    failure. This is helpful when debugging gradchecks.

  * **check_sparse_nnz** (*bool**, **optional*) -- if True,
    gradcheck allows for SparseTensor input, and for any
    SparseTensor at input, gradcheck will perform check at nnz
    positions only.

  * **nondet_tol** (*float**, **optional*) -- tolerance for non-