shrinath-suresh/blogs-docs-splitted huggingface dataset:
torch.nn.functional.pixel_shuffle
torch.nn.functional.pixel_shuffle(input, upscale_factor) -> Tensor
Rearranges elements in a tensor of shape (, C \times r^2, H, W) to
   a tensor of shape (, C, H \times r, W \times r), where r is the
   "upscale_factor".
See "PixelShuffle" for details.
Parameters:
      * input (Tensor) -- the input tensor
  * **upscale_factor** (*int*) -- factor to increase spatial
    resolution by

Examples:
  >>> input = torch.randn(1, 9, 4, 4)
  >>> output = torch.nn.functional.pixel_shuffle(input, 3)
  >>> print(output.size())
  torch.Size([1, 1, 12, 12])
ConvBnReLU3d
class torch.ao.nn.intrinsic.qat.ConvBnReLU3d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=None, padding_mode='zeros', eps=1e-05, momentum=0.1, freeze_bn=False, qconfig=None)
A ConvBnReLU3d module is a module fused from Conv3d, BatchNorm3d
   and ReLU, attached with FakeQuantize modules for weight, used in
   quantization aware training.
We combined the interface of "torch.nn.Conv3d" and
   "torch.nn.BatchNorm3d" and "torch.nn.ReLU".
Similar to torch.nn.Conv3d, with FakeQuantize modules initialized
   to default.
Variables:
      weight_fake_quant -- fake quant module for weight
torch.logical_xor
torch.logical_xor(input, other, *, out=None) -> Tensor
Computes the element-wise logical XOR of the given input tensors.
   Zeros are treated as "False" and nonzeros are treated as "True".
Parameters:
      * input (Tensor) -- the input tensor.
  * **other** (*Tensor*) -- the tensor to compute XOR with

Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> torch.logical_xor(torch.tensor([True, False, True]), torch.tensor([True, False, False]))
  tensor([False, False,  True])
  >>> a = torch.tensor([0, 1, 10, 0], dtype=torch.int8)
  >>> b = torch.tensor([4, 0, 1, 0], dtype=torch.int8)
  >>> torch.logical_xor(a, b)
  tensor([ True,  True, False, False])
  >>> torch.logical_xor(a.double(), b.double())
  tensor([ True,  True, False, False])
  >>> torch.logical_xor(a.double(), b)
  tensor([ True,  True, False, False])
SobolEngine
class torch.quasirandom.SobolEngine(dimension, scramble=False, seed=None)
The "torch.quasirandom.SobolEngine" is an engine for generating
   (scrambled) Sobol sequences. Sobol sequences are an example of low
   discrepancy quasi-random sequences.
This implementation of an engine for Sobol sequences is capable of
   sampling sequences up to a maximum dimension of 21201. It uses
   direction numbers from https://web.maths.unsw.edu.au/~fkuo/sobol/
   obtained using the search criterion D(6) up to the dimension 21201.
   This is the recommended choice by the authors.
-[ References ]-


Art B. Owen. Scrambling Sobol and Niederreiter-Xing points.
     Journal of Complexity, 14(4):466-489, December 1998.


I. M. Sobol. The distribution of points in a cube and the
     accurate evaluation of integrals. Zh. Vychisl. Mat. i Mat. Phys.,
     7:784-802, 1967.


Parameters:
      * dimension (Int) -- The dimensionality of the sequence to
        be drawn
be drawn
  * **scramble** (*bool**, **optional*) -- Setting this to "True"
    will produce scrambled Sobol sequences. Scrambling is capable
    of producing better Sobol sequences. Default: "False".

  * **seed** (*Int**, **optional*) -- This is the seed for the
    scrambling. The seed of the random number generator is set to
    this, if specified. Otherwise, it uses a random seed. Default:
    "None"

Examples:
  >>> soboleng = torch.quasirandom.SobolEngine(dimension=5)
  >>> soboleng.draw(3)
  tensor([[0.0000, 0.0000, 0.0000, 0.0000, 0.0000],
          [0.5000, 0.5000, 0.5000, 0.5000, 0.5000],
          [0.7500, 0.2500, 0.2500, 0.2500, 0.7500]])

draw(n=1, out=None, dtype=torch.float32)
  Function to draw a sequence of "n" points from a Sobol sequence.
  Note that the samples are dependent on the previous samples. The
  size of the result is (n, dimension).

  Parameters:
Parameters:
         * n (Int, optional) -- The length of sequence of
           points to draw. Default: 1
     * **out** (*Tensor**, **optional*) -- The output tensor

     * **dtype** ("torch.dtype", optional) -- the desired data
       type of the returned tensor. Default: "torch.float32"

  Return type:
     *Tensor*

draw_base2(m, out=None, dtype=torch.float32)
  Function to draw a sequence of "2**m" points from a Sobol
  sequence. Note that the samples are dependent on the previous
  samples. The size of the result is (2**m, dimension).

  Parameters:
     * **m** (*Int*) -- The (base2) exponent of the number of
       points to draw.

     * **out** (*Tensor**, **optional*) -- The output tensor

     * **dtype** ("torch.dtype", optional) -- the desired data
       type of the returned tensor. Default: "torch.float32"

  Return type:
     *Tensor*

fast_forward(n)
PackedSequence
class torch.nn.utils.rnn.PackedSequence(data, batch_sizes=None, sorted_indices=None, unsorted_indices=None)
Holds the data and list of "batch_sizes" of a packed sequence.
All RNN modules accept packed sequences as inputs.
Note:
 Instances of this class should never be created manually. They
 are meant to be instantiated by functions like
 "pack_padded_sequence()".Batch sizes represent the number
 elements at each sequence step in the batch, not the varying
 sequence lengths passed to "pack_padded_sequence()".  For
 instance, given data "abc" and "x" the "PackedSequence" would
 contain data "axbc" with "batch_sizes=[2,1,1]".

Variables:
      * data (Tensor) -- Tensor containing packed sequence
  * **batch_sizes** (*Tensor*) -- Tensor of integers holding
    information about the batch size at each sequence step

  * **sorted_indices** (*Tensor**, **optional*) -- Tensor of
integers holding how this "PackedSequence" is constructed from
        sequences.
  * **unsorted_indices** (*Tensor**, **optional*) -- Tensor of
    integers holding how this to recover the original sequences
    with correct order.

Note:
 "data" can be on arbitrary device and of arbitrary dtype.
 "sorted_indices" and "unsorted_indices" must be "torch.int64"
 tensors on the same device as "data".However, "batch_sizes"
 should always be a CPU "torch.int64" tensor.This invariant is
 maintained throughout "PackedSequence" class, and all functions
 that construct a *:class:PackedSequence* in PyTorch (i.e., they
 only pass in tensors conforming to this constraint).

batch_sizes: Tensor
  Alias for field number 1

count(value, /)
  Return number of occurrences of value.

data: Tensor
  Alias for field number 0

index(value, start=0, stop=9223372036854775807, /)
  Return first index of value.
Return first index of value.
  Raises ValueError if the value is not present.

property is_cuda
  Returns true if *self.data* stored on a gpu

is_pinned()
  Returns true if *self.data* stored on in pinned memory

sorted_indices: Optional[Tensor]
  Alias for field number 2

to(args, *kwargs)
  Performs dtype and/or device conversion on *self.data*.

  It has similar signature as "torch.Tensor.to()", except optional
  arguments like *non_blocking* and *copy* should be passed as
  kwargs, not args, or they will not apply to the index tensors.

  Note:

    If the "self.data" Tensor already has the correct
    "torch.dtype" and "torch.device", then "self" is returned.
    Otherwise, returns a copy with the desired configuration.

unsorted_indices: Optional[Tensor]
  Alias for field number 3
Softplus
class torch.nn.Softplus(beta=1, threshold=20)
Applies the Softplus function \text{Softplus}(x) = \frac{1}{\beta}
   * \log(1 + \exp(\beta * x)) element-wise.
SoftPlus is a smooth approximation to the ReLU function and can be
   used to constrain the output of a machine to always be positive.
For numerical stability the implementation reverts to the linear
   function when input \times \beta > threshold.
Parameters:
      * beta (int) -- the \beta value for the Softplus
        formulation. Default: 1
  * **threshold** (*int*) -- values above this revert to a linear
    function. Default: 20

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

[image]
Examples:
  >>> m = nn.Softplus()
  >>> input = torch.randn(2)
  >>> output = m(input)
torch.logical_or
torch.logical_or(input, other, *, out=None) -> Tensor
Computes the element-wise logical OR of the given input tensors.
   Zeros are treated as "False" and nonzeros are treated as "True".
Parameters:
      * input (Tensor) -- the input tensor.
  * **other** (*Tensor*) -- the tensor to compute OR with

Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> torch.logical_or(torch.tensor([True, False, True]), torch.tensor([True, False, False]))
  tensor([ True, False,  True])
  >>> a = torch.tensor([0, 1, 10, 0], dtype=torch.int8)
  >>> b = torch.tensor([4, 0, 1, 0], dtype=torch.int8)
  >>> torch.logical_or(a, b)
  tensor([ True,  True,  True, False])
  >>> torch.logical_or(a.double(), b.double())
  tensor([ True,  True,  True, False])
  >>> torch.logical_or(a.double(), b)
  tensor([ True,  True,  True, False])
threshold
class torch.ao.nn.quantized.functional.threshold(input, threshold, value)
Applies the quantized version of the threshold function element-
   wise:
  x = \begin{cases}         x & \text{if~} x > \text{threshold} \\
  \text{value} & \text{otherwise}     \end{cases}

See "Threshold" for more details.
Return type:
      Tensor
MarginRankingLoss
class torch.nn.MarginRankingLoss(margin=0.0, size_average=None, reduce=None, reduction='mean')
Creates a criterion that measures the loss given inputs x1, x2, two
   1D mini-batch or 0D Tensors, and a label 1D mini-batch or 0D
   Tensor y (containing 1 or -1).
If y = 1 then it assumed the first input should be ranked higher
   (have a larger value) than the second input, and vice-versa for y =
   -1.
The loss function for each pair of samples in the mini-batch is:
  \text{loss}(x1, x2, y) = \max(0, -y * (x1 - x2) + \text{margin})

Parameters:
      * margin (float, optional) -- Has a default value of
        0.
  * **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:
Shape:
      * Input1: (N) or () where N is the batch size.
  * Input2: (N) or (), same shape as the Input1.

  * Target: (N) or (), same shape as the inputs.

  * Output: scalar. If "reduction" is "'none'" and Input size is
    not (), then (N).

Examples:
  >>> loss = nn.MarginRankingLoss()
  >>> input1 = torch.randn(3, requires_grad=True)
  >>> input2 = torch.randn(3, requires_grad=True)
  >>> target = torch.randn(3).sign()
  >>> output = loss(input1, input2, target)
  >>> output.backward()
LocalResponseNorm
class torch.nn.LocalResponseNorm(size, alpha=0.0001, beta=0.75, k=1.0)
Applies local response normalization over an input signal composed
   of several input planes, where channels occupy the second
   dimension. Applies normalization across channels.
  b_{c} = a_{c}\left(k + \frac{\alpha}{n} \sum_{c'=\max(0,
  c-n/2)}^{\min(N-1,c+n/2)}a_{c'}^2\right)^{-\beta}

Parameters:
      * size (int) -- amount of neighbouring channels used for
        normalization
  * **alpha** (*float*) -- multiplicative factor. Default: 0.0001

  * **beta** (*float*) -- exponent. Default: 0.75

  * **k** (*float*) -- additive factor. Default: 1

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

Examples:
  >>> lrn = nn.LocalResponseNorm(2)
  >>> signal_2d = torch.randn(32, 5, 24, 24)
  >>> signal_4d = torch.randn(16, 5, 7, 7, 7, 7)
  >>> output_2d = lrn(signal_2d)
  >>> output_4d = lrn(signal_4d)
torch.jit.trace_module
torch.jit.trace_module(mod, inputs, optimize=None, check_trace=True, check_inputs=None, check_tolerance=1e-05, strict=True, _force_outplace=False, _module_class=None, _compilation_unit=, example_inputs_is_kwarg=False)
Trace a module and return an executable "ScriptModule" that will be
   optimized using just-in-time compilation. When a module is passed
   to "torch.jit.trace", only the "forward" method is run and traced.
   With "trace_module", you can specify a dictionary of method names
   to example inputs to trace (see the "inputs") argument below.
See "torch.jit.trace" for more information on tracing.
Parameters:
      * mod (torch.nn.Module) -- A "torch.nn.Module" containing
        methods whose names are specified in "inputs". The given
        methods will be compiled as a part of a single ScriptModule.
  * **inputs** (*dict*) -- A dict containing sample inputs indexed
by method names in "mod". The inputs will be passed to methods
        whose names correspond to inputs' keys while tracing. "{
        'forward' : example_forward_input, 'method2':
        example_method2_input}"
Keyword Arguments:
      * check_trace ("bool", optional) -- Check if the same inputs
        run through traced code produce the same outputs. Default:
        "True". You might want to disable this if, for example, your
        network contains non- deterministic ops or if you are sure
        that the network is correct despite a checker failure.
  * **check_inputs** (*list of dicts**, **optional*) -- A list of
    dicts of input arguments that should be used to check the
    trace against what is expected. Each tuple is equivalent to a
    set of input arguments that would be specified in "inputs".
    For best results, pass in a set of checking inputs
    representative of the space of shapes and types of inputs you
expect the network to see. If not specified, the original
        "inputs" are used for checking
  * **check_tolerance** (*float**, **optional*) -- Floating-point
    comparison tolerance to use in the checker procedure. This can
    be used to relax the checker strictness in the event that
    results diverge numerically for a known reason, such as
    operator fusion.

  * **example_inputs_is_kwarg** ("bool", optional) -- This
    parameter indicate whether the example inputs is a pack pack
    of keyword arguments. Default: "False".

Returns:
      A "ScriptModule" object with a single "forward" method
      containing the traced code. When "func" is a "torch.nn.Module",
      the returned "ScriptModule" will have the same set of sub-
      modules and parameters as "func".
Example (tracing a module with multiple methods):
  import torch
  import torch.nn as nn

  class Net(nn.Module):
      def __init__(self):
def init(self):
              super(Net, self).init()
              self.conv = nn.Conv2d(1, 1, 3)
      def forward(self, x):
          return self.conv(x)

      def weighted_kernel_sum(self, weight):
          return weight * self.conv.weight


  n = Net()
  example_weight = torch.rand(1, 1, 3, 3)
  example_forward_input = torch.rand(1, 1, 3, 3)

  # Trace a specific method and construct `ScriptModule` with
  # a single `forward` method
  module = torch.jit.trace(n.forward, example_forward_input)

  # Trace a module (implicitly traces `forward`) and construct a
  # `ScriptModule` with a single `forward` method
  module = torch.jit.trace(n, example_forward_input)

  # Trace specific methods on a module (specified in `inputs`), constructs
  # a `ScriptModule` with `forward` and `weighted_kernel_sum` methods
  inputs = {'forward' : example_forward_input, 'weighted_kernel_sum' : example_weight}
ReplicationPad2d
class torch.nn.ReplicationPad2d(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 4-tuple,
      uses (\text{padding_left}, \text{padding_right},
      \text{padding_top}, \text{padding_bottom})
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} = H_{in} + \text{padding\_top} +
    \text{padding\_bottom}

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

Examples:
  >>> m = nn.ReplicationPad2d(2)
  >>> input = torch.arange(9, dtype=torch.float).reshape(1, 1, 3, 3)
  >>> input
  tensor([[[[0., 1., 2.],
            [3., 4., 5.],
            [6., 7., 8.]]]])
[6., 7., 8.]]]])
      >>> m(input)
      tensor([[[[0., 0., 0., 1., 2., 2., 2.],
                [0., 0., 0., 1., 2., 2., 2.],
                [0., 0., 0., 1., 2., 2., 2.],
                [3., 3., 3., 4., 5., 5., 5.],
                [6., 6., 6., 7., 8., 8., 8.],
                [6., 6., 6., 7., 8., 8., 8.],
                [6., 6., 6., 7., 8., 8., 8.]]]])
      >>> # using different paddings for different sides
      >>> m = nn.ReplicationPad2d((1, 1, 2, 0))
      >>> m(input)
      tensor([[[[0., 0., 1., 2., 2.],
                [0., 0., 1., 2., 2.],
                [0., 0., 1., 2., 2.],
                [3., 3., 4., 5., 5.],
                [6., 6., 7., 8., 8.]]]])
torch.Tensor.to_dense
Tensor.to_dense() -> Tensor
Creates a strided copy of "self" if "self" is not a strided tensor,
   otherwise returns "self".
Example:
  >>> s = torch.sparse_coo_tensor(
  ...        torch.tensor([[1, 1],
  ...                      [0, 2]]),
  ...        torch.tensor([9, 10]),
  ...        size=(3, 3))
  >>> s.to_dense()
  tensor([[ 0,  0,  0],
          [ 9,  0, 10],
          [ 0,  0,  0]])
Dropout
class torch.nn.Dropout(p=0.5, inplace=False)
During training, randomly zeroes some of the elements of the input
   tensor with probability "p" using samples from a Bernoulli
   distribution. Each channel will be zeroed out independently on
   every forward call.
This has proven to be an effective technique for regularization and
   preventing the co-adaptation of neurons as described in the paper
   Improving neural networks by preventing co-adaptation of feature
   detectors .
Furthermore, the outputs are scaled by a factor of \frac{1}{1-p}
   during training. This means that during evaluation the module
   simply computes an identity function.
Parameters:
      * p (float) -- probability of an element to be zeroed.
        Default: 0.5
  * **inplace** (*bool*) -- If set to "True", will do this
    operation in-place. Default: "False"

Shape:
      * Input: (*). Input can be of any shape
  * Output: (*). Output is of the same shape as input
avg_pool2d
class torch.ao.nn.quantized.functional.avg_pool2d(input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True, divisor_override=None)
Applies 2D average-pooling operation in kH \times kW regions by
   step size sH \times sW steps. The number of output features is
   equal to the number of input planes.
Note:
 The input quantization parameters propagate to the output.

See "AvgPool2d" for details and output shape.
Parameters:
      * input -- quantized input tensor (\text{minibatch} ,
        \text{in_channels} , iH , iW)
  * **kernel_size** -- size of the pooling region. Can be a single
    number or a tuple *(kH, kW)*

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

  * **padding** -- implicit zero paddings on both sides of the
    input. Can be a single number or a tuple *(padH, padW)*.
    Default: 0
Linear
class torch.ao.nn.quantized.dynamic.Linear(in_features, out_features, bias_=True, dtype=torch.qint8)
A dynamic quantized linear module with floating point tensor as
   inputs and outputs. We adopt the same interface as
   torch.nn.Linear, please see
   https://pytorch.org/docs/stable/nn.html#torch.nn.Linear for
   documentation.
Similar to "torch.nn.Linear", 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 which are of shape (\text{out_features},
        \text{in_features}).
  * **bias** (*Tensor*) -- the non-learnable floating point bias
    of the module of shape (\text{out\_features}). If "bias" is
    "True", the values are initialized to zero.

Examples:
  >>> m = nn.quantized.dynamic.Linear(20, 30)
  >>> input = torch.randn(128, 20)
  >>> output = m(input)
  >>> print(output.size())
print(output.size())
      torch.Size([128, 30])



classmethod from_float(mod)
  Create a dynamic 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

classmethod from_reference(ref_qlinear)
  Create a (fbgemm/qnnpack) dynamic quantized module from a
  reference quantized module :param ref_qlinear: a reference
  quantized  module, either produced by :type ref_qlinear: Module
  :param torch.ao.quantization functions or provided by the user:
LazyLinear
class torch.nn.LazyLinear(out_features, bias=True, device=None, dtype=None)
A "torch.nn.Linear" module where in_features is inferred.
In this module, the weight and bias are of
   "torch.nn.UninitializedParameter" class. They will be initialized
   after the first call to "forward" is done and the module will
   become a regular "torch.nn.Linear" module. The "in_features"
   argument of the "Linear" is inferred from the "input.shape[-1]".
Check the "torch.nn.modules.lazy.LazyModuleMixin" for further
   documentation on lazy modules and their limitations.
Parameters:
      * out_features (int) -- size of each output sample
  * **bias** (*UninitializedParameter*) -- If set to "False", the
    layer will not learn an additive bias. Default: "True"

Variables:
      * weight (torch.nn.parameter.UninitializedParameter) --
        the learnable weights of the module of shape
        (\text{out_features}, \text{in_features}). The values are
initialized from \mathcal{U}(-\sqrt{k}, \sqrt{k}), where k =
        \frac{1}{\text{in_features}}
  * **bias** (*torch.nn.parameter.UninitializedParameter*) -- the
    learnable bias of the module of shape (\text{out\_features}).
    If "bias" is "True", the values are initialized from
    \mathcal{U}(-\sqrt{k}, \sqrt{k}) where k =
    \frac{1}{\text{in\_features}}

cls_to_become
  alias of "Linear"
MultiheadAttention
class torch.nn.quantizable.MultiheadAttention(embed_dim, num_heads, dropout=0.0, bias=True, add_bias_kv=False, add_zero_attn=False, kdim=None, vdim=None, batch_first=False, device=None, dtype=None)
dequantize()
  Utility to convert the quantized MHA back to float.

  The motivation for this is that it is not trivial to conver the
  weights from the format that is used in the quantized version
  back to the float.

forward(query, key, value, key_padding_mask=None, need_weights=True, attn_mask=None, average_attn_weights=True, is_causal=False)
  Note::
     Please, refer to "forward()" for more information

  Parameters:
     * **query** (*Tensor*) -- map a query and a set of key-value
       pairs to an output. See "Attention Is All You Need" for
       more details.

     * **key** (*Tensor*) -- map a query and a set of key-value
       pairs to an output. See "Attention Is All You Need" for
       more details.