shrinath-suresh/blogs-docs-splitted huggingface dataset:
"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 tuples**, **optional*) -- A list of
    tuples 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
    "example_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 "example_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.
operator fusion.
  * **strict** ("bool", optional) -- run the tracer in a strict
    mode or not (default: "True"). Only turn this off when you
    want the tracer to record your mutable container types
    (currently "list"/"dict") and you are sure that the container
    you are using in your problem is a "constant" structure and
    does not get used as control flow (if, for) conditions.

  * **example_kwarg_inputs** (*dict**, **optional*) -- This
    parameter is a pack of keyword arguments of example inputs
    that will be passed to the function while tracing. Default:
    "None". Either this argument or "example_inputs" should be
    specified. The dict will be unpacking by the arguments name of
    the traced function. If the keys of the dict don't not match
    with the traced function's arguments name, a runtime exception
    will be raised.

Returns:
      If func is nn.Module or "forward" of nn.Module, trace
returns a "ScriptModule" object with a single "forward" method
      containing the traced code.  The returned ScriptModule will
      have the same set of sub-modules and parameters as the original
      "nn.Module".  If "func" is a standalone function, "trace"
      returns ScriptFunction.
Example (tracing a function):
  import torch

  def foo(x, y):
      return 2 * x + y

  # Run `foo` with the provided inputs and record the tensor operations
  traced_foo = torch.jit.trace(foo, (torch.rand(3), torch.rand(3)))

  # `traced_foo` can now be run with the TorchScript interpreter or saved
  # and loaded in a Python-free environment

Example (tracing an existing module):
  import torch
  import torch.nn as nn

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

      def forward(self, x):
          return self.conv(x)

  n = Net()
return self.conv(x)
  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)
Unflatten
class torch.nn.Unflatten(dim, unflattened_size)
Unflattens a tensor dim expanding it to a desired shape. For use
   with "Sequential".


"dim" specifies the dimension of the input tensor to be
     unflattened, and it can be either int or str when Tensor or
     NamedTensor is used, respectively.


"unflattened_size" is the new shape of the unflattened dimension
     of the tensor and it can be a tuple of ints or a list of ints
     or torch.Size for Tensor input;  a NamedShape (tuple of
     (name, size) tuples) for NamedTensor input.


Shape:
      * Input: (, S_{\text{dim}}, ), where S_{\text{dim}} is the
        size at dimension "dim" and * means any number of dimensions
        including none.
  * Output: (*, U_1, ..., U_n, *), where U = "unflattened_size"
    and \prod_{i=1}^n U_i = S_{\text{dim}}.

Parameters:
      * dim (Union[int, str]) -- Dimension to be
        unflattened
unflattened
  * **unflattened_size** (*Union**[**torch.Size**, **Tuple**,
    **List**, **NamedShape**]*) -- New shape of the unflattened
    dimension

-[ Examples ]-



input = torch.randn(2, 50)
With tuple of ints
m = nn.Sequential(
    nn.Linear(50, 50),
    nn.Unflatten(1, (2, 5, 5))
)
output = m(input)
output.size()
   torch.Size([2, 2, 5, 5])
With torch.Size
m = nn.Sequential(
    nn.Linear(50, 50),
    nn.Unflatten(1, torch.Size([2, 5, 5]))
)
output = m(input)
output.size()
   torch.Size([2, 2, 5, 5])
With namedshape (tuple of tuples)
input = torch.randn(2, 50, names=('N', 'features'))
unflatten = nn.Unflatten('features', (('C', 2), ('H', 5), ('W', 5)))
output = unflatten(input)
output.size()
   torch.Size([2, 2, 5, 5])
torch.outer
torch.outer(input, vec2, *, out=None) -> Tensor
Outer product of "input" and "vec2". If "input" is a vector of size
   n and "vec2" is a vector of size m, then "out" must be a matrix of
   size (n \times m).
Note:
 This function does not broadcast.

Parameters:
      * input (Tensor) -- 1-D input vector
  * **vec2** (*Tensor*) -- 1-D input vector

Keyword Arguments:
      out (Tensor, optional) -- optional output matrix
Example:
  >>> v1 = torch.arange(1., 5.)
  >>> v2 = torch.arange(1., 4.)
  >>> torch.outer(v1, v2)
  tensor([[  1.,   2.,   3.],
          [  2.,   4.,   6.],
          [  3.,   6.,   9.],
          [  4.,   8.,  12.]])
torch.nn.functional.avg_pool3d
torch.nn.functional.avg_pool3d(input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True, divisor_override=None) -> Tensor
Applies 3D average-pooling operation in kT \times kH \times kW
   regions by step size sT \times sH \times sW steps. The number of
   output features is equal to \lfloor\frac{\text{input
   planes}}{sT}\rfloor.
See "AvgPool3d" for details and output shape.
Parameters:
      * input -- input tensor (\text{minibatch} ,
        \text{in_channels} , iT \times iH , iW)
  * **kernel_size** -- size of the pooling region. Can be a single
    number or a tuple *(kT, kH, kW)*

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

  * **padding** -- implicit zero paddings on both sides of the
    input. Can be a single number or a tuple *(padT, padH, padW)*,
    Default: 0
Default: 0
  * **ceil_mode** -- when True, will use *ceil* instead of *floor*
    in the formula to compute the output shape

  * **count_include_pad** -- when True, will include the zero-
    padding in the averaging calculation

  * **divisor_override** -- if specified, it will be used as
    divisor, otherwise size of the pooling region will be used.
    Default: None
LinearReLU
class torch.ao.nn.intrinsic.quantized.dynamic.LinearReLU(in_features, out_features, bias=True, dtype=torch.qint8)
A LinearReLU module fused from Linear and ReLU modules that can be
   used for dynamic quantization. Supports both, FP16 and INT8
   quantization.
We adopt the same interface as
   "torch.ao.nn.quantized.dynamic.Linear".
Variables:
      torch.ao.nn.quantized.dynamic.Linear (Same as) --
Examples:
  >>> m = nn.intrinsic.quantized.dynamic.LinearReLU(20, 30)
  >>> input = torch.randn(128, 20)
  >>> output = m(input)
  >>> print(output.size())
  torch.Size([128, 30])
torch.nn.functional.adaptive_max_pool2d
torch.nn.functional.adaptive_max_pool2d(args, *kwargs)
Applies a 2D adaptive max pooling over an input signal composed of
   several input planes.
See "AdaptiveMaxPool2d" for details and output shape.
Parameters:
      * output_size -- the target output size (single integer or
        double-integer tuple)
  * **return_indices** -- whether to return pooling indices.
    Default: "False"
MaxUnpool1d
class torch.nn.MaxUnpool1d(kernel_size, stride=None, padding=0)
Computes a partial inverse of "MaxPool1d".
"MaxPool1d" is not fully invertible, since the non-maximal values
   are lost.
"MaxUnpool1d" takes in as input the output of "MaxPool1d" including
   the indices of the maximal values and computes a partial inverse in
   which all non-maximal values are set to zero.
Note:
 "MaxPool1d" can map several input sizes to the same output sizes.
 Hence, the inversion process can get ambiguous. To accommodate
 this, you can provide the needed output size as an additional
 argument "output_size" in the forward call. See the Inputs and
 Example below.

Parameters:
      * kernel_size (int or tuple) -- Size of the max
        pooling window.
  * **stride** (*int** or **tuple*) -- Stride of the max pooling
    window. It is set to "kernel_size" by default.

  * **padding** (*int** or **tuple*) -- Padding that was added to
the input
Inputs:
      * input: the input Tensor to invert
  * *indices*: the indices given out by "MaxPool1d"

  * *output_size* (optional): the targeted output size

Shape:
      * Input: (N, C, H_{in}) or (C, H_{in}).
  * Output: (N, C, H_{out}) or (C, H_{out}), where

       H_{out} = (H_{in} - 1) \times \text{stride}[0] - 2 \times
       \text{padding}[0] + \text{kernel\_size}[0]

    or as given by "output_size" in the call operator

Example:
  >>> pool = nn.MaxPool1d(2, stride=2, return_indices=True)
  >>> unpool = nn.MaxUnpool1d(2, stride=2)
  >>> input = torch.tensor([[[1., 2, 3, 4, 5, 6, 7, 8]]])
  >>> output, indices = pool(input)
  >>> unpool(output, indices)
  tensor([[[ 0.,  2.,  0.,  4.,  0.,  6.,  0., 8.]]])

  >>> # Example showcasing the use of output_size
  >>> input = torch.tensor([[[1., 2, 3, 4, 5, 6, 7, 8, 9]]])
  >>> output, indices = pool(input)
torch.nn.functional.max_pool2d
torch.nn.functional.max_pool2d(input, kernel_size, stride=None, padding=0, dilation=1, ceil_mode=False, return_indices=False)
Applies a 2D max pooling over an input signal composed of several
   input planes.
Note:
 The order of "ceil_mode" and "return_indices" is different from
 what seen in "MaxPool2d", and will change in a future release.

See "MaxPool2d" for details.
Parameters:
      * input -- input tensor (\text{minibatch} ,
        \text{in_channels} , iH , iW), minibatch dim optional.
  * **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 negative infinity padding to be added
    on both sides, must be >= 0 and <= kernel_size / 2.
dilation -- The stride between elements within a sliding
        window, must be > 0.


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


return_indices -- If "True", will return the argmax along
    with the max values. Useful for
    "torch.nn.functional.max_unpool2d" later
QFunctional
class torch.ao.nn.quantized.QFunctional
Wrapper class for quantized operations.
The instance of this class can be used instead of the
   "torch.ops.quantized" prefix. See example usage below.
Note:
 This class does not provide a "forward" hook. Instead, you must
 use one of the underlying functions (e.g. "add").

Examples:
  >>> q_add = QFunctional()
  >>> a = torch.quantize_per_tensor(torch.tensor(3.0), 1.0, 0, torch.qint32)
  >>> b = torch.quantize_per_tensor(torch.tensor(4.0), 1.0, 0, torch.qint32)
  >>> q_add.add(a, b)  # Equivalent to ``torch.ops.quantized.add(a, b, 1.0, 0)``

Valid operation names:
      * add
  * cat

  * mul

  * add_relu

  * add_scalar

  * mul_scalar
LazyBatchNorm1d
class torch.nn.LazyBatchNorm1d(eps=1e-05, momentum=0.1, affine=True, track_running_stats=True, device=None, dtype=None)
A "torch.nn.BatchNorm1d" module with lazy initialization of the
   "num_features" argument of the "BatchNorm1d" that is inferred from
   the "input.size(1)". The attributes that will be lazily initialized
   are weight, bias, running_mean and running_var.
Check the "torch.nn.modules.lazy.LazyModuleMixin" for further
   documentation on lazy modules and their limitations.
Parameters:
      * eps (float) -- a value added to the denominator for
        numerical stability. Default: 1e-5
  * **momentum** (*float*) -- the value used for the running_mean
    and running_var computation. Can be set to "None" for
    cumulative moving average (i.e. simple average). Default: 0.1

  * **affine** (*bool*) -- a boolean value that when set to
    "True", this module has learnable affine parameters. Default:
    "True"
"True"
  * **track_running_stats** (*bool*) -- a boolean value that when
    set to "True", this module tracks the running mean and
    variance, and when set to "False", this module does not track
    such statistics, and initializes statistics buffers
    "running_mean" and "running_var" as "None". When these buffers
    are "None", this module always uses batch statistics. in both
    training and eval modes. Default: "True"

cls_to_become
  alias of "BatchNorm1d"
torch.fliplr
torch.fliplr(input) -> Tensor
Flip tensor in the left/right direction, returning a new tensor.
Flip the entries in each row in the left/right direction. Columns
   are preserved, but appear in a different order than before.
Note:
 Requires the tensor to be at least 2-D.

Note:
 *torch.fliplr* makes a copy of "input"'s data. This is different
 from NumPy's *np.fliplr*, which returns a view in constant time.
 Since copying a tensor's data is more work than viewing that
 data, *torch.fliplr* is expected to be slower than *np.fliplr*.

Parameters:
      input (Tensor) -- Must be at least 2-dimensional.
Example:
  >>> x = torch.arange(4).view(2, 2)
  >>> x
  tensor([[0, 1],
          [2, 3]])
  >>> torch.fliplr(x)
  tensor([[1, 0],
          [3, 2]])
EmbeddingBag
class torch.nn.EmbeddingBag(num_embeddings, embedding_dim, max_norm=None, norm_type=2.0, scale_grad_by_freq=False, mode='mean', sparse=False, _weight=None, include_last_offset=False, padding_idx=None, device=None, dtype=None)
Computes sums or means of 'bags' of embeddings, without
   instantiating the intermediate embeddings.
For bags of constant length, no "per_sample_weights", no indices
   equal to "padding_idx", and with 2D inputs, this class
  * with "mode="sum"" is equivalent to "Embedding" followed by
    "torch.sum(dim=1)",

  * with "mode="mean"" is equivalent to "Embedding" followed by
    "torch.mean(dim=1)",

  * with "mode="max"" is equivalent to "Embedding" followed by
    "torch.max(dim=1)".

However, "EmbeddingBag" is much more time and memory efficient than
   using a chain of these operations.
EmbeddingBag also supports per-sample weights as an argument to the
   forward pass. This scales the output of the Embedding before
performing a weighted reduction as specified by "mode". If
   "per_sample_weights" is passed, the only supported "mode" is
   ""sum"", which computes a weighted sum according to
   "per_sample_weights".
Parameters:
      * num_embeddings (int) -- size of the dictionary of
        embeddings
  * **embedding_dim** (*int*) -- the size of each embedding vector

  * **max_norm** (*float**, **optional*) -- If given, each
    embedding vector with norm larger than "max_norm" is
    renormalized to have norm "max_norm".

  * **norm_type** (*float**, **optional*) -- The p of the p-norm
    to compute for the "max_norm" option. Default "2".

  * **scale_grad_by_freq** (*bool**, **optional*) -- if given,
    this will scale gradients by the inverse of frequency of the
    words in the mini-batch. Default "False". Note: this option is
    not supported when "mode="max"".

  * **mode** (*str**, **optional*) -- ""sum"", ""mean"" or
""max"". Specifies the way to reduce the bag. ""sum"" computes
        the weighted sum, taking "per_sample_weights" into
        consideration. ""mean"" computes the average of the values in
        the bag, ""max"" computes the max value over each bag.
        Default: ""mean""
  * **sparse** (*bool**, **optional*) -- if "True", gradient
    w.r.t. "weight" matrix will be a sparse tensor. See Notes for
    more details regarding sparse gradients. Note: this option is
    not supported when "mode="max"".

  * **include_last_offset** (*bool**, **optional*) -- if "True",
    "offsets" has one additional element, where the last element
    is equivalent to the size of *indices*. This matches the CSR
    format.

  * **padding_idx** (*int**, **optional*) -- If specified, the
    entries at "padding_idx" do not contribute to the gradient;
    therefore, the embedding vector at "padding_idx" is not
updated during training, i.e. it remains as a fixed "pad". For
        a newly constructed EmbeddingBag, the embedding vector at
        "padding_idx" will default to all zeros, but can be updated to
        another value to be used as the padding vector. Note that the
        embedding vector at "padding_idx" is excluded from the
        reduction.
Variables:
      weight (Tensor) -- the learnable weights of the module of
      shape (num_embeddings, embedding_dim) initialized from
      \mathcal{N}(0, 1).
Examples:
  >>> # an EmbeddingBag module containing 10 tensors of size 3
  >>> embedding_sum = nn.EmbeddingBag(10, 3, mode='sum')
  >>> # a batch of 2 samples of 4 indices each
  >>> input = torch.tensor([1, 2, 4, 5, 4, 3, 2, 9], dtype=torch.long)
  >>> offsets = torch.tensor([0, 4], dtype=torch.long)
  >>> embedding_sum(input, offsets)
  tensor([[-0.8861, -5.4350, -0.0523],
          [ 1.1306, -2.5798, -1.0044]])
[ 1.1306, -2.5798, -1.0044]])
  >>> # Example with padding_idx
  >>> embedding_sum = nn.EmbeddingBag(10, 3, mode='sum', padding_idx=2)
  >>> input = torch.tensor([2, 2, 2, 2, 4, 3, 2, 9], dtype=torch.long)
  >>> offsets = torch.tensor([0, 4], dtype=torch.long)
  >>> embedding_sum(input, offsets)
  tensor([[ 0.0000,  0.0000,  0.0000],
          [-0.7082,  3.2145, -2.6251]])

  >>> # An EmbeddingBag can be loaded from an Embedding like so
  >>> embedding = nn.Embedding(10, 3, padding_idx=2)
  >>> embedding_sum = nn.EmbeddingBag.from_pretrained(
          embedding.weight,
          padding_idx=embedding.padding_idx,
          mode='sum')

forward(input, offsets=None, per_sample_weights=None)
  Forward pass of EmbeddingBag.

  Parameters:
     * **input** (*Tensor*) -- Tensor containing bags of indices
       into the embedding matrix.

     * **offsets** (*Tensor**, **optional*) -- Only used when
"input" is 1D. "offsets" determines the starting index
           position of each bag (sequence) in "input".
     * **per_sample_weights** (*Tensor**, **optional*) -- a tensor
       of float / double weights, or None to indicate all weights
       should be taken to be "1". If specified,
       "per_sample_weights" must have exactly the same shape as
       input and is treated as having the same "offsets", if those
       are not "None". Only supported for "mode='sum'".

  Returns:
     Tensor output shape of *(B, embedding_dim)*.

  Return type:
     *Tensor*

  Note:

    A few notes about "input" and "offsets":

    * "input" and "offsets" have to be of the same type, either
      int or long

    * If "input" is 2D of shape *(B, N)*, it will be treated as
      "B" bags (sequences) each of fixed length "N", and this will
      return "B" values aggregated in a way depending on the
"mode". "offsets" is ignored and required to be "None" in
          this case.
    * If "input" is 1D of shape *(N)*, it will be treated as a
      concatenation of multiple bags (sequences).  "offsets" is
      required to be a 1D tensor containing the starting index
      positions of each bag in "input". Therefore, for "offsets"
      of shape *(B)*, "input" will be viewed as having "B" bags.
      Empty bags (i.e., having 0-length) will have returned
      vectors filled by zeros.

classmethod from_pretrained(embeddings, freeze=True, max_norm=None, norm_type=2.0, scale_grad_by_freq=False, mode='mean', sparse=False, include_last_offset=False, padding_idx=None)
  Creates EmbeddingBag instance from given 2-dimensional
  FloatTensor.

  Parameters:
     * **embeddings** (*Tensor*) -- FloatTensor containing weights
       for the EmbeddingBag. First dimension is being passed to
       EmbeddingBag as 'num_embeddings', second as
'embedding_dim'.
     * **freeze** (*bool**, **optional*) -- If "True", the tensor
       does not get updated in the learning process. Equivalent to
       "embeddingbag.weight.requires_grad = False". Default:
       "True"

     * **max_norm** (*float**, **optional*) -- See module
       initialization documentation. Default: "None"

     * **norm_type** (*float**, **optional*) -- See module
       initialization documentation. Default "2".

     * **scale_grad_by_freq** (*bool**, **optional*) -- See module
       initialization documentation. Default "False".

     * **mode** (*str**, **optional*) -- See module initialization
       documentation. Default: ""mean""

     * **sparse** (*bool**, **optional*) -- See module
       initialization documentation. Default: "False".

     * **include_last_offset** (*bool**, **optional*) -- See
       module initialization documentation. Default: "False".
padding_idx (int, optional) -- See module
           initialization documentation. Default: "None".
Return type:
     EmbeddingBag
Examples:
 >>> # FloatTensor containing pretrained weights
 >>> weight = torch.FloatTensor([[1, 2.3, 3], [4, 5.1, 6.3]])
 >>> embeddingbag = nn.EmbeddingBag.from_pretrained(weight)
 >>> # Get embeddings for index 1
 >>> input = torch.LongTensor([[1, 0]])
 >>> embeddingbag(input)
 tensor([[ 2.5000,  3.7000,  4.6500]])
torch.Tensor.index_copy_
Tensor.index_copy_(dim, index, tensor) -> Tensor
Copies the elements of "tensor" into the "self" tensor by selecting
   the indices in the order given in "index". For example, if "dim ==
   0" and "index[i] == j", then the "i"th row of "tensor" is copied to
   the "j"th row of "self".
The "dim"th dimension of "tensor" must have the same size as the
   length of "index" (which must be a vector), and all other
   dimensions must match "self", or an error will be raised.
Note:
 If "index" contains duplicate entries, multiple elements from
 "tensor" will be copied to the same index of "self". The result
 is nondeterministic since it depends on which copy occurs last.

Parameters:
      * dim (int) -- dimension along which to index
  * **index** (*LongTensor*) -- indices of "tensor" to select from

  * **tensor** (*Tensor*) -- the tensor containing values to copy

Example:
  >>> x = torch.zeros(5, 3)
Example:
  >>> x = torch.zeros(5, 3)
  >>> t = torch.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=torch.float)
  >>> index = torch.tensor([0, 4, 2])
  >>> x.index_copy_(0, index, t)
  tensor([[ 1.,  2.,  3.],
          [ 0.,  0.,  0.],
          [ 7.,  8.,  9.],
          [ 0.,  0.,  0.],
          [ 4.,  5.,  6.]])
MultiheadAttention
class torch.nn.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)
Allows the model to jointly attend to information from different
   representation subspaces as described in the paper: Attention Is
   All You Need.
Multi-Head Attention is defined as:
  \text{MultiHead}(Q, K, V) =
  \text{Concat}(head_1,\dots,head_h)W^O

where head_i = \text{Attention}(QW_i^Q, KW_i^K, VW_i^V).
"forward()" will use a special optimized implementation if all of
   the following conditions are met:


self attention is being computed (i.e., "query", "key", and
     "value" are the same tensor. This restriction will be loosened in
     the future.)


inputs are batched (3D) with "batch_first==True"


Either autograd is disabled (using "torch.inference_mode" or
     "torch.no_grad") or no tensor argument "requires_grad"