shrinath-suresh/blogs-docs-splitted huggingface dataset:
"clone()" and "detach()" are recommended.
Parameters:
      data (array_like) -- The returned Tensor copies "data".
Keyword Arguments:
      * dtype ("torch.dtype", optional) -- the desired type of
        returned tensor. Default: if None, same "torch.dtype" as this
        tensor.
  * **device** ("torch.device", optional) -- the desired device of
    returned tensor. Default: if None, same "torch.device" as this
    tensor.

  * **requires_grad** (*bool**, **optional*) -- If autograd should
    record operations on the returned tensor. Default: "False".

  * **layout** ("torch.layout", optional) -- the desired layout of
    returned Tensor. Default: "torch.strided".

  * **pin_memory** (*bool**, **optional*) -- If set, returned
    tensor would be allocated in the pinned memory. Works only for
    CPU tensors. Default: "False".

Example:
  >>> tensor = torch.ones((2,), dtype=torch.int8)
  >>> data = [[0, 1], [2, 3]]
torch.set_printoptions
torch.set_printoptions(precision=None, threshold=None, edgeitems=None, linewidth=None, profile=None, sci_mode=None)
Set options for printing. Items shamelessly taken from NumPy
Parameters:
      * precision -- Number of digits of precision for floating
        point output (default = 4).
  * **threshold** -- Total number of array elements which trigger
    summarization rather than full *repr* (default = 1000).

  * **edgeitems** -- Number of array items in summary at beginning
    and end of each dimension (default = 3).

  * **linewidth** -- The number of characters per line for the
    purpose of inserting line breaks (default = 80). Thresholded
    matrices will ignore this parameter.

  * **profile** -- Sane defaults for pretty printing. Can override
    with any of the above options. (any one of *default*, *short*,
    *full*)

  * **sci_mode** -- Enable (True) or disable (False) scientific
notation. If None (default) is specified, the value is defined
        by torch._tensor_str._Formatter. This value is automatically
        chosen by the framework.
Example:
  >>> # Limit the precision of elements
  >>> torch.set_printoptions(precision=2)
  >>> torch.tensor([1.12345])
  tensor([1.12])
  >>> # Limit the number of elements shown
  >>> torch.set_printoptions(threshold=5)
  >>> torch.arange(10)
  tensor([0, 1, 2, ..., 7, 8, 9])
  >>> # Restore defaults
  >>> torch.set_printoptions(profile='default')
  >>> torch.tensor([1.12345])
  tensor([1.1235])
  >>> torch.arange(10)
  tensor([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
torch.jit.ignore
torch.jit.ignore(drop=False, **kwargs)
This decorator indicates to the compiler that a function or method
   should be ignored and left as a Python function. This allows you to
   leave code in your model that is not yet TorchScript compatible. If
   called from TorchScript, ignored functions will dispatch the call
   to the Python interpreter. Models with ignored functions cannot be
   exported; use "@torch.jit.unused" instead.
Example (using "@torch.jit.ignore" on a method):
  import torch
  import torch.nn as nn

  class MyModule(nn.Module):
      @torch.jit.ignore
      def debugger(self, x):
          import pdb
          pdb.set_trace()

      def forward(self, x):
          x += 10
          # The compiler would normally try to compile `debugger`,
          # but since it is `@ignore`d, it will be left as a call
          # to Python
          self.debugger(x)
          return x
return x
  m = torch.jit.script(MyModule())

  # Error! The call `debugger` cannot be saved since it calls into Python
  m.save("m.pt")

Example (using "@torch.jit.ignore(drop=True)" on a method):
  import torch
  import torch.nn as nn

  class MyModule(nn.Module):
      @torch.jit.ignore(drop=True)
      def training_method(self, x):
          import pdb
          pdb.set_trace()

      def forward(self, x):
          if self.training:
              self.training_method(x)
          return x

  m = torch.jit.script(MyModule())

  # This is OK since `training_method` is not saved, the call is replaced
  # with a `raise`.
  m.save("m.pt")
torch.nn.functional.adaptive_avg_pool2d
torch.nn.functional.adaptive_avg_pool2d(input, output_size)
Applies a 2D adaptive average pooling over an input signal composed
   of several input planes.
See "AdaptiveAvgPool2d" for details and output shape.
Parameters:
      output_size (None) -- the target output size (single
      integer or double-integer tuple)
Return type:
      Tensor
torch.sparse_bsc_tensor
torch.sparse_bsc_tensor(ccol_indices, row_indices, values, size=None, *, dtype=None, device=None, requires_grad=False, check_invariants=None) -> Tensor
Constructs a sparse tensor in BSC (Block Compressed Sparse Column))
   with specified 2-dimensional blocks at the given "ccol_indices" and
   "row_indices". Sparse matrix multiplication operations in BSC
   format are typically faster than that for sparse tensors in COO
   format. Make you have a look at the note on the data type of the
   indices.
Note:
 If the "device" argument is not specified the device of the given
 "values" and indices tensor(s) must match. If, however, the
 argument is specified the input Tensors will be converted to the
 given device and in turn determine the device of the constructed
 sparse tensor.

Parameters:
      * ccol_indices (array_like) -- (B+1)-dimensional array of
        size "(*batchsize, ncolblocks + 1)". The last element of each
batch is the number of non-zeros. This tensor encodes the
        index in values and row_indices depending on where the given
        column starts. Each successive number in the tensor subtracted
        by the number before it denotes the number of elements in a
        given column.
  * **row_indices** (*array_like*) -- Row block co-ordinates of
    each block in values. (B+1)-dimensional tensor with the same
    length as values.

  * **values** (*array_list*) -- Initial blocks for the tensor.
    Can be a list, tuple, NumPy "ndarray", and other types that
    represents a (1 + 2 + K)-dimensional tensor where "K" is the
    number of dense dimensions.

  * **size** (list, tuple, "torch.Size", optional) -- Size of the
    sparse tensor: "(*batchsize, nrows * blocksize[0], ncols *
    blocksize[1], *densesize)" If not provided, the size will be
    inferred as the minimum size big enough to hold all non-zero
    blocks.

Keyword Arguments:
blocks.
Keyword Arguments:
      * dtype ("torch.dtype", optional) -- the desired data type
        of returned tensor.  Default: if None, infers data type from
        "values".
  * **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".

  * **check_invariants** (*bool**, **optional*) -- If sparse
    tensor invariants are checked. Default: as returned by
    "torch.sparse.check_sparse_tensor_invariants.is_enabled()",
    initially False.

Example::
      >>> ccol_indices = [0, 1, 2]
      >>> row_indices = [0, 1]
row_indices = [0, 1]
      >>> values = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
      >>> torch.sparse_bsc_tensor(torch.tensor(ccol_indices, dtype=torch.int64),
      ...                         torch.tensor(row_indices, dtype=torch.int64),
      ...                         torch.tensor(values), dtype=torch.double)
      tensor(ccol_indices=tensor([0, 1, 2]),
             row_indices=tensor([0, 1]),
             values=tensor([[[1., 2.],
                             [3., 4.]],
                            [[5., 6.],
                             [7., 8.]]]), size=(2, 2), nnz=2, dtype=torch.float64,
             layout=torch.sparse_bsc)
LSTM
class torch.nn.LSTM(args, *kwargs)
Applies a multi-layer long short-term memory (LSTM) RNN to an input
   sequence.
For each element in the input sequence, each layer computes the
   following function:
  \begin{array}{ll} \\     i_t = \sigma(W_{ii} x_t + b_{ii} +
  W_{hi} h_{t-1} + b_{hi}) \\     f_t = \sigma(W_{if} x_t + b_{if}
  + W_{hf} h_{t-1} + b_{hf}) \\     g_t = \tanh(W_{ig} x_t +
  b_{ig} + W_{hg} h_{t-1} + b_{hg}) \\     o_t = \sigma(W_{io} x_t
  + b_{io} + W_{ho} h_{t-1} + b_{ho}) \\     c_t = f_t \odot
  c_{t-1} + i_t \odot g_t \\     h_t = o_t \odot \tanh(c_t) \\
  \end{array}

where h_t is the hidden state at time t, c_t is the cell state at
   time t, x_t is the input at time t, h_{t-1} is the hidden state
   of the layer at time t-1 or the initial hidden state at time 0,
   and i_t, f_t, g_t, o_t are the input, forget, cell, and output
   gates, respectively. \sigma is the sigmoid function, and \odot is
   the Hadamard product.
the Hadamard product.
In a multilayer LSTM, the input x^{(l)}_t of the l -th layer (l >=
   2) is the hidden state h^{(l-1)}_t of the previous layer multiplied
   by dropout \delta^{(l-1)}_t where each \delta^{(l-1)}_t is a
   Bernoulli random variable which is 0 with probability "dropout".
If "proj_size > 0" is specified, LSTM with projections will be
   used. This changes the LSTM cell in the following way. First, the
   dimension of h_t will be changed from "hidden_size" to "proj_size"
   (dimensions of W_{hi} will be changed accordingly). Second, the
   output hidden state of each layer will be multiplied by a learnable
   projection matrix: h_t = W_{hr}h_t. Note that as a consequence of
   this, the output of LSTM network will be of different shape as
   well. See Inputs/Outputs sections below for exact dimensions of all
   variables. You can find more details in
   https://arxiv.org/abs/1402.1128.
Parameters:
      * input_size -- The number of expected features in the input
x
  * **hidden_size** -- The number of features in the hidden state
    *h*

  * **num_layers** -- Number of recurrent layers. E.g., setting
    "num_layers=2" would mean stacking two LSTMs together to form
    a *stacked LSTM*, with the second LSTM taking in outputs of
    the first LSTM and computing the final results. Default: 1

  * **bias** -- If "False", then the layer does not use bias
    weights *b_ih* and *b_hh*. Default: "True"

  * **batch_first** -- If "True", then the input and output
    tensors are provided as *(batch, seq, feature)* instead of
    *(seq, batch, feature)*. Note that this does not apply to
    hidden or cell states. See the Inputs/Outputs sections below
    for details.  Default: "False"

  * **dropout** -- If non-zero, introduces a *Dropout* layer on
    the outputs of each LSTM layer except the last layer, with
    dropout probability equal to "dropout". Default: 0
bidirectional -- If "True", becomes a bidirectional LSTM.
        Default: "False"

proj_size -- If "> 0", will use LSTM with projections of
    corresponding size. Default: 0



Inputs: input, (h_0, c_0)
      * input: tensor of shape (L, H_{in}) for unbatched input,
        (L, N, H_{in}) when "batch_first=False" or (N, L, H_{in}) when
        "batch_first=True" containing the features of the input
        sequence.  The input can also be a packed variable length
        sequence. See "torch.nn.utils.rnn.pack_padded_sequence()" or
        "torch.nn.utils.rnn.pack_sequence()" for details.
  * **h_0**: tensor of shape (D * \text{num\_layers}, H_{out}) for
    unbatched input or (D * \text{num\_layers}, N, H_{out})
    containing the initial hidden state for each element in the
    input sequence. Defaults to zeros if (h_0, c_0) is not
    provided.

  * **c_0**: tensor of shape (D * \text{num\_layers}, H_{cell})
for unbatched input or (D * \text{num_layers}, N, H_{cell})
        containing the initial cell state for each element in the
        input sequence. Defaults to zeros if (h_0, c_0) is not
        provided.
  where:

     \begin{aligned}     N ={} & \text{batch size} \\     L ={} &
     \text{sequence length} \\     D ={} & 2 \text{ if
     bidirectional=True otherwise } 1 \\     H_{in} ={} &
     \text{input\_size} \\     H_{cell} ={} & \text{hidden\_size}
     \\     H_{out} ={} & \text{proj\_size if }
     \text{proj\_size}>0 \text{ otherwise hidden\_size} \\
     \end{aligned}

Outputs: output, (h_n, c_n)
      * output: tensor of shape (L, D * H_{out}) for unbatched
        input, (L, N, D * H_{out}) when "batch_first=False" or (N, L,
        D * H_{out}) when "batch_first=True" containing the output
        features (h_t) from the last layer of the LSTM, for each
        t. If a "torch.nn.utils.rnn.PackedSequence" has been given
as the input, the output will also be a packed sequence. When
        "bidirectional=True", output will contain a concatenation of
        the forward and reverse hidden states at each time step in the
        sequence.
  * **h_n**: tensor of shape (D * \text{num\_layers}, H_{out}) for
    unbatched input or (D * \text{num\_layers}, N, H_{out})
    containing the final hidden state for each element in the
    sequence. When "bidirectional=True", *h_n* will contain a
    concatenation of the final forward and reverse hidden states,
    respectively.

  * **c_n**: tensor of shape (D * \text{num\_layers}, H_{cell})
    for unbatched input or (D * \text{num\_layers}, N, H_{cell})
    containing the final cell state for each element in the
    sequence. When "bidirectional=True", *c_n* will contain a
    concatenation of the final forward and reverse cell states,
    respectively.

Variables:
respectively.
Variables:
      * weight_ih_l[k] -- the learnable input-hidden weights of
        the \text{k}^{th} layer (W_ii|W_if|W_ig|W_io), of shape
        (4hidden_size, input_size) for k = 0. Otherwise, the
        shape is (4hidden_size, num_directions * hidden_size). If
        "proj_size > 0" was specified, the shape will be
        (4hidden_size, num_directions * proj_size) for k > 0*
  * **weight_hh_l[k]** -- the learnable hidden-hidden weights of
    the \text{k}^{th} layer *(W_hi|W_hf|W_hg|W_ho)*, of shape
    *(4*hidden_size, hidden_size)*. If "proj_size > 0" was
    specified, the shape will be *(4*hidden_size, proj_size)*.

  * **bias_ih_l[k]** -- the learnable input-hidden bias of the
    \text{k}^{th} layer *(b_ii|b_if|b_ig|b_io)*, of shape
    *(4*hidden_size)*

  * **bias_hh_l[k]** -- the learnable hidden-hidden bias of the
    \text{k}^{th} layer *(b_hi|b_hf|b_hg|b_ho)*, of shape
    *(4*hidden_size)*
(4hidden_size)*
  * **weight_hr_l[k]** -- the learnable projection weights of the
    \text{k}^{th} layer of shape *(proj_size, hidden_size)*. Only
    present when "proj_size > 0" was specified.

  * **weight_ih_l[k]_reverse** -- Analogous to *weight_ih_l[k]*
    for the reverse direction. Only present when
    "bidirectional=True".

  * **weight_hh_l[k]_reverse** -- Analogous to *weight_hh_l[k]*
    for the reverse direction. Only present when
    "bidirectional=True".

  * **bias_ih_l[k]_reverse** -- Analogous to *bias_ih_l[k]* for
    the reverse direction. Only present when "bidirectional=True".

  * **bias_hh_l[k]_reverse** -- Analogous to *bias_hh_l[k]* for
    the reverse direction. Only present when "bidirectional=True".

  * **weight_hr_l[k]_reverse** -- Analogous to *weight_hr_l[k]*
    for the reverse direction. Only present when
    "bidirectional=True" and "proj_size > 0" was specified.

Note:
Note:
 All the weights and biases are initialized from
 \mathcal{U}(-\sqrt{k}, \sqrt{k}) where k =
 \frac{1}{\text{hidden\_size}}

Note:
 For bidirectional LSTMs, forward and backward are directions 0
 and 1 respectively. Example of splitting the output layers when
 "batch_first=False": "output.view(seq_len, batch, num_directions,
 hidden_size)".

Note:
 For bidirectional LSTMs, *h_n* is not equivalent to the last
 element of *output*; the former contains the final forward and
 reverse hidden states, while the latter contains the final
 forward hidden state and the initial reverse hidden state.

Note:
 "batch_first" argument is ignored for unbatched inputs.

Warning:
 There are known non-determinism issues for RNN functions on some
 versions of cuDNN and CUDA. You can enforce deterministic
 behavior by setting the following environment variables:On CUDA
 10.1, set environment variable "CUDA_LAUNCH_BLOCKING=1". This may
affect performance.On CUDA 10.2 or later, set environment
     variable (note the leading colon symbol)
     "CUBLAS_WORKSPACE_CONFIG=:16:8" or
     "CUBLAS_WORKSPACE_CONFIG=:4096:2".See the cuDNN 8 Release Notes
     for more information.
Note:
 If the following conditions are satisfied: 1) cudnn is enabled,
 2) input data is on the GPU 3) input data has dtype
 "torch.float16" 4) V100 GPU is used, 5) input data is not in
 "PackedSequence" format persistent algorithm can be selected to
 improve performance.

Examples:
  >>> rnn = nn.LSTM(10, 20, 2)
  >>> input = torch.randn(5, 3, 10)
  >>> h0 = torch.randn(2, 3, 20)
  >>> c0 = torch.randn(2, 3, 20)
  >>> output, (hn, cn) = rnn(input, (h0, c0))
torch.zeros_like
torch.zeros_like(input, *, dtype=None, layout=None, device=None, requires_grad=False, memory_format=torch.preserve_format) -> Tensor
Returns a tensor filled with the scalar value 0, with the same
   size as "input". "torch.zeros_like(input)" is equivalent to
   "torch.zeros(input.size(), dtype=input.dtype, layout=input.layout,
   device=input.device)".
Warning:
 As of 0.4, this function does not support an "out" keyword. As an
 alternative, the old "torch.zeros_like(input, out=output)" is
 equivalent to "torch.zeros(input.size(), out=output)".

Parameters:
      input (Tensor) -- the size of "input" will determine size
      of the output tensor.
Keyword Arguments:
      * dtype ("torch.dtype", optional) -- the desired data type
        of returned Tensor. Default: if "None", defaults to the dtype
        of "input".
  * **layout** ("torch.layout", optional) -- the desired layout of
returned tensor. Default: if "None", defaults to the layout of
        "input".
  * **device** ("torch.device", optional) -- the desired device of
    returned tensor. Default: if "None", defaults to the device of
    "input".

  * **requires_grad** (*bool**, **optional*) -- If autograd should
    record operations on the returned tensor. Default: "False".

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

Example:
  >>> input = torch.empty(2, 3)
  >>> torch.zeros_like(input)
  tensor([[ 0.,  0.,  0.],
          [ 0.,  0.,  0.]])
torch.hsplit
torch.hsplit(input, indices_or_sections) -> List of Tensors
Splits "input", a tensor with one or more dimensions, into multiple
   tensors horizontally according to "indices_or_sections". Each split
   is a view of "input".
If "input" is one dimensional this is equivalent to calling
   torch.tensor_split(input, indices_or_sections, dim=0) (the split
   dimension is zero), and if "input" has two or more dimensions it's
   equivalent to calling torch.tensor_split(input,
   indices_or_sections, dim=1) (the split dimension is 1), except that
   if "indices_or_sections" is an integer it must evenly divide the
   split dimension or a runtime error will be thrown.
This function is based on NumPy's "numpy.hsplit()".
Parameters:
      * input (Tensor) -- tensor to split.
  * **indices_or_sections** (*int** or **list** or **tuple of
    ints*) -- See argument in "torch.tensor_split()".

Example::
      >>> t = torch.arange(16.0).reshape(4,4)
      >>> t
t
      tensor([[ 0.,  1.,  2.,  3.],
              [ 4.,  5.,  6.,  7.],
              [ 8.,  9., 10., 11.],
              [12., 13., 14., 15.]])
      >>> torch.hsplit(t, 2)
      (tensor([[ 0.,  1.],
               [ 4.,  5.],
               [ 8.,  9.],
               [12., 13.]]),
       tensor([[ 2.,  3.],
               [ 6.,  7.],
               [10., 11.],
               [14., 15.]]))
      >>> torch.hsplit(t, [3, 6])
      (tensor([[ 0.,  1.,  2.],
               [ 4.,  5.,  6.],
               [ 8.,  9., 10.],
               [12., 13., 14.]]),
       tensor([[ 3.],
               [ 7.],
               [11.],
               [15.]]),
       tensor([], size=(4, 0)))
ConvBn3d
class torch.ao.nn.intrinsic.qat.ConvBn3d(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 ConvBn3d module is a module fused from Conv3d and BatchNorm3d,
   attached with FakeQuantize modules for weight, used in quantization
   aware training.
We combined the interface of "torch.nn.Conv3d" and
   "torch.nn.BatchNorm3d".
Similar to "torch.nn.Conv3d", with FakeQuantize modules initialized
   to default.
Variables:
      * freeze_bn --
  * **weight_fake_quant** -- fake quant module for weight
BCELoss
class torch.nn.BCELoss(weight=None, size_average=None, reduce=None, reduction='mean')
Creates a criterion that measures the Binary Cross Entropy between
   the target and the input probabilities:
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 x_n + (1 - y_n) \cdot \log (1 - 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}

This is used for measuring the error of a reconstruction in for
   example an auto-encoder. Note that the targets y should be numbers
   between 0 and 1.
Notice that if x_n is either 0 or 1, one of the log terms would be
mathematically undefined in the above loss equation. PyTorch
   chooses to set \log (0) = -\infty, since \lim_{x\to 0} \log (x) =
   -\infty. However, an infinite term in the loss equation is not
   desirable for several reasons.
For one, if either y_n = 0 or (1 - y_n) = 0, then we would be
   multiplying 0 with infinity. Secondly, if we have an infinite loss
   value, then we would also have an infinite term in our gradient,
   since \lim_{x\to 0} \frac{d}{dx} \log (x) = \infty. This would make
   BCELoss's backward method nonlinear with respect to x_n, and using
   it for things like linear regression would not be straight-forward.
Our solution is that BCELoss clamps its log function outputs to be
   greater than or equal to -100. This way, we can always have a
   finite loss value and a linear backward method.
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'"
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:
  >>> m = nn.Sigmoid()
  >>> loss = nn.BCELoss()
  >>> input = torch.randn(3, requires_grad=True)
  >>> target = torch.empty(3).random_(2)
  >>> output = loss(m(input), target)
  >>> output.backward()