shrinath-suresh/blogs-docs-splitted huggingface dataset:
ps://github.com/pytorch/pytorch/pull/60521#issuecomment-867061780
     for more details.
Parameters:
      * tensors (Sequence[Tensor] or Tensor) -- Tensors
        of which the derivative will be computed.
  * **grad_tensors** (*Sequence**[**Tensor** or **None**] or
    **Tensor**, **optional*) -- The "vector" in the Jacobian-
    vector product, usually gradients w.r.t. each element of
    corresponding tensors. None values can be specified for scalar
    Tensors or ones that don't require grad. If a None value would
    be acceptable for all grad_tensors, then this argument is
    optional.

  * **retain_graph** (*bool**, **optional*) -- If "False", the
    graph used to compute the grad will be freed. Note that in
    nearly all cases setting this option to "True" is not needed
    and often can be worked around in a much more efficient way.
    Defaults to the value of "create_graph".
Defaults to the value of "create_graph".
  * **create_graph** (*bool**, **optional*) -- If "True", graph of
    the derivative will be constructed, allowing to compute higher
    order derivative products. Defaults to "False".

  * **inputs** (*Sequence**[**Tensor**] or **Tensor**,
    **optional*) -- Inputs w.r.t. which the gradient be will
    accumulated into ".grad". All other Tensors will be ignored.
    If not provided, the gradient is accumulated into all the leaf
    Tensors that were used to compute the attr::tensors.
torch.geqrf
torch.geqrf(input, *, out=None)
This is a low-level function for calling LAPACK's geqrf directly.
   This function returns a namedtuple (a, tau) as defined in LAPACK
   documentation for geqrf .
Computes a QR decomposition of "input". Both Q and R matrices
   are stored in the same output tensor a. The elements of R are
   stored on and above the diagonal. Elementary reflectors (or
   Householder vectors) implicitly defining matrix Q are stored
   below the diagonal. The results of this function can be used
   together with "torch.linalg.householder_product()" to obtain the
   Q matrix or with "torch.ormqr()", which uses an implicit
   representation of the Q matrix, for an efficient matrix-matrix
   multiplication.
See LAPACK documentation for geqrf for further details.
Note:
 See also "torch.linalg.qr()", which computes Q and R matrices,
 and "torch.linalg.lstsq()" with the "driver="gels"" option for a
torch.autograd.Function.backward
static Function.backward(ctx, *grad_outputs)
Defines a formula for differentiating the operation with backward
   mode automatic differentiation (alias to the vjp function).
This function is to be overridden by all subclasses.
It must accept a context "ctx" as the first argument, followed by
   as many outputs as the "forward()" returned (None will be passed in
   for non tensor outputs of the forward function), and it should
   return as many tensors, as there were inputs to "forward()". Each
   argument is the gradient w.r.t the given output, and each returned
   value should be the gradient w.r.t. the corresponding input. If an
   input is not a Tensor or is a Tensor not requiring grads, you can
   just pass None as a gradient for that input.
The context can be used to retrieve tensors saved during the
   forward pass. It also has an attribute "ctx.needs_input_grad" as a
torch.cumprod
torch.cumprod(input, dim, *, dtype=None, out=None) -> Tensor
Returns the cumulative product of elements of "input" in the
   dimension "dim".
For example, if "input" is a vector of size N, the result will also
   be a vector of size N, with elements.
  y_i = x_1 \times x_2\times x_3\times \dots \times x_i

Parameters:
      * input (Tensor) -- the input tensor.
  * **dim** (*int*) -- the dimension to do the operation over

Keyword Arguments:
      * dtype ("torch.dtype", optional) -- the desired data type
        of returned tensor. If specified, the input tensor is casted
        to "dtype" before the operation is performed. This is useful
        for preventing data type overflows. Default: None.
  * **out** (*Tensor**, **optional*) -- the output tensor.

Example:
  >>> a = torch.randn(10)
  >>> a
  tensor([ 0.6001,  0.2069, -0.1919,  0.9792,  0.6727,  1.0062,  0.4126,
          -0.2129, -0.4206,  0.1968])
-0.2129, -0.4206,  0.1968])
      >>> torch.cumprod(a, dim=0)
      tensor([ 0.6001,  0.1241, -0.0238, -0.0233, -0.0157, -0.0158, -0.0065,
               0.0014, -0.0006, -0.0001])
  >>> a[5] = 0.0
  >>> torch.cumprod(a, dim=0)
  tensor([ 0.6001,  0.1241, -0.0238, -0.0233, -0.0157, -0.0000, -0.0000,
           0.0000, -0.0000, -0.0000])
torch.rsqrt
torch.rsqrt(input, *, out=None) -> Tensor
Returns a new tensor with the reciprocal of the square-root of each
   of the elements of "input".
  \text{out}_{i} = \frac{1}{\sqrt{\text{input}_{i}}}

Parameters:
      input (Tensor) -- the input tensor.
Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> a = torch.randn(4)
  >>> a
  tensor([-0.0370,  0.2970,  1.5420, -0.9105])
  >>> torch.rsqrt(a)
  tensor([    nan,  1.8351,  0.8053,     nan])
torch.dstack
torch.dstack(tensors, *, out=None) -> Tensor
Stack tensors in sequence depthwise (along third axis).
This is equivalent to concatenation along the third axis after 1-D
   and 2-D tensors have been reshaped by "torch.atleast_3d()".
Parameters:
      tensors (sequence of Tensors) -- sequence of tensors to
      concatenate
Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> a = torch.tensor([1, 2, 3])
  >>> b = torch.tensor([4, 5, 6])
  >>> torch.dstack((a,b))
  tensor([[[1, 4],
           [2, 5],
           [3, 6]]])
  >>> a = torch.tensor([[1],[2],[3]])
  >>> b = torch.tensor([[4],[5],[6]])
  >>> torch.dstack((a,b))
  tensor([[[1, 4]],
          [[2, 5]],
          [[3, 6]]])
torch.dist
torch.dist(input, other, p=2) -> Tensor
Returns the p-norm of ("input" - "other")
The shapes of "input" and "other" must be broadcastable.
Parameters:
      * input (Tensor) -- the input tensor.
  * **other** (*Tensor*) -- the Right-hand-side input tensor

  * **p** (*float**, **optional*) -- the norm to be computed

Example:
  >>> x = torch.randn(4)
  >>> x
  tensor([-1.5393, -0.8675,  0.5916,  1.6321])
  >>> y = torch.randn(4)
  >>> y
  tensor([ 0.0967, -1.0511,  0.6295,  0.8360])
  >>> torch.dist(x, y, 3.5)
  tensor(1.6727)
  >>> torch.dist(x, y, 3)
  tensor(1.6973)
  >>> torch.dist(x, y, 0)
  tensor(4.)
  >>> torch.dist(x, y, 1)
  tensor(2.6537)
torch.func.vjp
torch.func.vjp(func, *primals, has_aux=False)
Standing for the vector-Jacobian product, returns a tuple
   containing the results of "func" applied to "primals" and a
   function that, when given "cotangents", computes the reverse-mode
   Jacobian of "func" with respect to "primals" times "cotangents".
Parameters:
      * func (Callable) -- A Python function that takes one or
        more arguments. Must return one or more Tensors.
  * **primals** (*Tensors*) -- Positional arguments to "func" that
    must all be Tensors. The returned function will also be
    computing the derivative with respect to these arguments

  * **has_aux** (*bool*) -- Flag indicating that "func" returns a
    "(output, aux)" tuple where the first element is the output of
    the function to be differentiated and the second element is
    other auxiliary objects that will not be differentiated.
    Default: False.

Returns:
Default: False.
Returns:
      Returns a "(output, vjp_fn)" tuple containing the output of
      "func" applied to "primals" and a function that computes the vjp
      of "func" with respect to all "primals" using the cotangents
      passed to the returned function. If "has_aux is True", then
      instead returns a "(output, vjp_fn, aux)" tuple. The returned
      "vjp_fn" function will return a tuple of each VJP.
When used in simple cases, "vjp()" behaves the same as "grad()"



x = torch.randn([5])
f = lambda x: x.sin().sum()
(_, vjpfunc) = torch.func.vjp(f, x)
grad = vjpfunc(torch.tensor(1.))[0]
assert torch.allclose(grad, torch.func.grad(f)(x))



However, "vjp()" can support functions with multiple outputs by
   passing in the cotangents for each of the outputs



x = torch.randn([5])
f = lambda x: (x.sin(), x.cos())
(_, vjpfunc) = torch.func.vjp(f, x)
vjps = vjpfunc((torch.ones([5]), torch.ones([5])))
assert torch.allclose(vjps[0], x.cos() + -x.sin())



"vjp()" can even support outputs being Python structs



x = torch.randn([5])
f = lambda x: {'first': x.sin(), 'second': x.cos()}
(_, vjpfunc) = torch.func.vjp(f, x)
cotangents = {'first': torch.ones([5]), 'second': torch.ones([5])}
vjps = vjpfunc(cotangents)
assert torch.allclose(vjps[0], x.cos() + -x.sin())



The function returned by "vjp()" will compute the partials with
   respect to each of the "primals"



x, y = torch.randn([5, 4]), torch.randn([4, 5])
(_, vjpfunc) = torch.func.vjp(torch.matmul, x, y)
cotangents = torch.randn([5, 5])
vjps = vjpfunc(cotangents)
assert len(vjps) == 2
assert torch.allclose(vjps[0], torch.matmul(cotangents, y.transpose(0, 1)))
assert torch.allclose(vjps[1], torch.matmul(x.transpose(0, 1), cotangents))



"primals" are the positional arguments for "f". All kwargs use
   their default value



x = torch.randn([5])
x = torch.randn([5])
def f(x, scale=4.):
  return x * scale
(_, vjpfunc) = torch.func.vjp(f, x)
vjps = vjpfunc(torch.ones_like(x))
assert torch.allclose(vjps[0], torch.full(x.shape, 4.))



Note:
 Using PyTorch "torch.no_grad" together with "vjp". Case 1: Using
 "torch.no_grad" inside a function:

 >>> def f(x):
 >>>     with torch.no_grad():
 >>>         c = x ** 2
 >>>     return x - c

 In this case, "vjp(f)(x)" will respect the inner
 "torch.no_grad".Case 2: Using "vjp" inside "torch.no_grad"
 context manager:

 >>> with torch.no_grad():
 >>>     vjp(f)(x)

 In this case, "vjp" will respect the inner "torch.no_grad", but
 not the outer one. This is because "vjp" is a "function
 transform": its result should not depend on the result of a
 context manager outside of "f".
Tanhshrink
class torch.nn.Tanhshrink
Applies the element-wise function:
  \text{Tanhshrink}(x) = x - \tanh(x)

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

[image]
Examples:
  >>> m = nn.Tanhshrink()
  >>> input = torch.randn(2)
  >>> output = m(input)
Linear
class torch.ao.nn.qat.dynamic.Linear(in_features, out_features, bias=True, qconfig=None, device=None, dtype=None)
A linear module attached with FakeQuantize modules for weight, used
   for dynamic quantization aware training.
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, with FakeQuantize modules initialized
   to default.
MaxUnpool2d
class torch.nn.MaxUnpool2d(kernel_size, stride=None, padding=0)
Computes a partial inverse of "MaxPool2d".
"MaxPool2d" is not fully invertible, since the non-maximal values
   are lost.
"MaxUnpool2d" takes in as input the output of "MaxPool2d" including
   the indices of the maximal values and computes a partial inverse in
   which all non-maximal values are set to zero.
Note:
 "MaxPool2d" 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 "MaxPool2d"

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

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} - 1) \times \text{stride[0]} - 2 \times
       \text{padding[0]} + \text{kernel\_size[0]}

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

    or as given by "output_size" in the call operator

Example:
  >>> pool = nn.MaxPool2d(2, stride=2, return_indices=True)
  >>> unpool = nn.MaxUnpool2d(2, stride=2)
  >>> input = torch.tensor([[[[ 1.,  2.,  3.,  4.],
                              [ 5.,  6.,  7.,  8.],
                              [ 9., 10., 11., 12.],
                              [13., 14., 15., 16.]]]])
output, indices = pool(input)
      >>> unpool(output, indices)
      tensor([[[[  0.,   0.,   0.,   0.],
                [  0.,   6.,   0.,   8.],
                [  0.,   0.,   0.,   0.],
                [  0.,  14.,   0.,  16.]]]])
      >>> # Now using output_size to resolve an ambiguous size for the inverse
      >>> input = torch.torch.tensor([[[[ 1.,  2.,  3., 4., 5.],
                                        [ 6.,  7.,  8., 9., 10.],
                                        [11., 12., 13., 14., 15.],
                                        [16., 17., 18., 19., 20.]]]])
      >>> output, indices = pool(input)
      >>> # This call will not work without specifying output_size
      >>> unpool(output, indices, output_size=input.size())
      tensor([[[[ 0.,  0.,  0.,  0.,  0.],
                [ 0.,  7.,  0.,  9.,  0.],
                [ 0.,  0.,  0.,  0.,  0.],
                [ 0., 17.,  0., 19.,  0.]]]])
LSTMCell
class torch.ao.nn.quantized.dynamic.LSTMCell(args, *kwargs)
A long short-term memory (LSTM) cell.
A dynamic quantized LSTMCell module with floating point tensor as
   inputs and outputs. Weights are quantized to 8 bits. We adopt the
   same interface as torch.nn.LSTMCell, please see
   https://pytorch.org/docs/stable/nn.html#torch.nn.LSTMCell for
   documentation.
Examples:
  >>> rnn = nn.LSTMCell(10, 20)
  >>> input = torch.randn(6, 3, 10)
  >>> hx = torch.randn(3, 20)
  >>> cx = torch.randn(3, 20)
  >>> output = []
  >>> for i in range(6):
  ...     hx, cx = rnn(input[i], (hx, cx))
  ...     output.append(hx)
torch.sparse.sum
torch.sparse.sum(input, dim=None, dtype=None)
Returns the sum of each row of the sparse tensor "input" in the
   given dimensions "dim". If "dim" is a list of dimensions, reduce
   over all of them. When sum over all "sparse_dim", this method
   returns a dense tensor instead of a sparse tensor.
All summed "dim" are squeezed (see "torch.squeeze()"), resulting an
   output tensor having "dim" fewer dimensions than "input".
During backward, only gradients at "nnz" locations of "input" will
   propagate back. Note that the gradients of "input" is coalesced.
Parameters:
      * input (Tensor) -- the input sparse tensor
  * **dim** (*int** or **tuple of ints*) -- a dimension or a list
    of dimensions to reduce. Default: reduce over all dims.

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

Return type:
      Tensor
Example:
  >>> nnz = 3
Tensor
Example:
  >>> nnz = 3
  >>> dims = [5, 5, 2, 3]
  >>> I = torch.cat([torch.randint(0, dims[0], size=(nnz,)),
                     torch.randint(0, dims[1], size=(nnz,))], 0).reshape(2, nnz)
  >>> V = torch.randn(nnz, dims[2], dims[3])
  >>> size = torch.Size(dims)
  >>> S = torch.sparse_coo_tensor(I, V, size)
  >>> S
  tensor(indices=tensor([[2, 0, 3],
                         [2, 4, 1]]),
         values=tensor([[[-0.6438, -1.6467,  1.4004],
                         [ 0.3411,  0.0918, -0.2312]],

                        [[ 0.5348,  0.0634, -2.0494],
                         [-0.7125, -1.0646,  2.1844]],

                        [[ 0.1276,  0.1874, -0.6334],
                         [-1.9682, -0.5340,  0.7483]]]),
         size=(5, 5, 2, 3), nnz=3, layout=torch.sparse_coo)

  # when sum over only part of sparse_dims, return a sparse tensor
  >>> torch.sparse.sum(S, [1, 3])
  tensor(indices=tensor([[0, 2, 3]]),
tensor(indices=tensor([[0, 2, 3]]),
             values=tensor([[-1.4512,  0.4073],
                            [-0.8901,  0.2017],
                            [-0.3183, -1.7539]]),
             size=(5, 2), nnz=3, layout=torch.sparse_coo)
  # when sum over all sparse dim, return a dense tensor
  # with summed dims squeezed
  >>> torch.sparse.sum(S, [0, 1, 3])
  tensor([-2.6596, -1.1450])
torch.remainder
torch.remainder(input, other, *, out=None) -> Tensor
Computes Python's modulus operation entrywise.  The result has the
   same sign as the divisor "other" and its absolute value is less
   than that of "other".
It may also be defined in terms of "torch.div()" as
  torch.remainder(a, b) == a - a.div(b, rounding_mode="floor") * b

Supports broadcasting to a common shape, type promotion, and
   integer and float inputs.
Note:
 Complex inputs are not supported. In some cases, it is not
 mathematically possible to satisfy the definition of a modulo
 operation with complex numbers. See "torch.fmod()" for how
 division by zero is handled.

See also:
 "torch.fmod()" which implements C++'s std::fmod. This one is
 defined in terms of division rounding towards zero.

Parameters:
      * input (Tensor or Scalar) -- the dividend
  * **other** (*Tensor** or **Scalar*) -- the divisor

Keyword Arguments:
Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> torch.remainder(torch.tensor([-3., -2, -1, 1, 2, 3]), 2)
  tensor([ 1.,  0.,  1.,  1.,  0.,  1.])
  >>> torch.remainder(torch.tensor([1, 2, 3, 4, 5]), -1.5)
  tensor([ -0.5000, -1.0000,  0.0000, -0.5000, -1.0000 ])
torch.moveaxis
torch.moveaxis(input, source, destination) -> Tensor
Alias for "torch.movedim()".
This function is equivalent to NumPy's moveaxis function.
Examples:
  >>> t = torch.randn(3,2,1)
  >>> t
  tensor([[[-0.3362],
          [-0.8437]],

          [[-0.9627],
          [ 0.1727]],

          [[ 0.5173],
          [-0.1398]]])
  >>> torch.moveaxis(t, 1, 0).shape
  torch.Size([2, 3, 1])
  >>> torch.moveaxis(t, 1, 0)
  tensor([[[-0.3362],
          [-0.9627],
          [ 0.5173]],

          [[-0.8437],
          [ 0.1727],
          [-0.1398]]])
  >>> torch.moveaxis(t, (1, 2), (0, 1)).shape
  torch.Size([2, 1, 3])
  >>> torch.moveaxis(t, (1, 2), (0, 1))
  tensor([[[-0.3362, -0.9627,  0.5173]],

          [[-0.8437,  0.1727, -0.1398]]])
torch.ormqr
torch.ormqr(input, tau, other, left=True, transpose=False, *, out=None) -> Tensor
Computes the matrix-matrix multiplication of a product of
   Householder matrices with a general matrix.
Multiplies a m \times n matrix C (given by "other") with a matrix
   Q, where Q is represented using Householder reflectors (input,
   tau). See Representation of Orthogonal or Unitary Matrices for
   further details.
If "left" is True then op(Q) times C is computed, otherwise
   the result is C times op(Q). When "left" is True, the
   implicit matrix Q has size m \times m. It has size n \times n
   otherwise. If "transpose" is True then op is the conjugate
   transpose operation, otherwise it's a no-op.
Supports inputs of float, double, cfloat and cdouble dtypes. Also
   supports batched inputs, and, if the input is batched, the output
   is batched with the same dimensions.
See also:
 "torch.geqrf()" can be used to form the Householder
representation (input, tau) of matrix Q from the QR
     decomposition.
Note:
 This function supports backward but it is only fast when "(input,
 tau)" do not require gradients and/or "tau.size(-1)" is very
 small. ``

Parameters:
      * input (Tensor) -- tensor of shape (, mn, k) where ***
        is zero or more batch dimensions and mn equals to m or n*
        depending on the "left".
  * **tau** (*Tensor*) -- tensor of shape *(*, min(mn, k))* where
    *** is zero or more batch dimensions.

  * **other** (*Tensor*) -- tensor of shape *(*, m, n)* where ***
    is zero or more batch dimensions.

  * **left** (*bool*) -- controls the order of multiplication.

  * **transpose** (*bool*) -- controls whether the matrix *Q* is
    conjugate transposed or not.

Keyword Arguments:
      out (Tensor, optional) -- the output Tensor. Ignored
      if None. Default: None.
torch.cuda.set_sync_debug_mode
torch.cuda.set_sync_debug_mode(debug_mode)
Sets the debug mode for cuda synchronizing operations.
Parameters:
      debug_mode (str or int) -- if "default" or 0, don't
      error or warn on synchronizing operations, if "warn" or 1, warn
      on synchronizing operations, if "error" or 2, error out
      synchronizing operations.
Warning:
 This is an experimental feature, and not all synchronizing
 operations will trigger warning or error. In particular,
 operations in torch.distributed and torch.sparse namespaces are
 not covered yet.
torch.log10
torch.log10(input, *, out=None) -> Tensor
Returns a new tensor with the logarithm to the base 10 of the
   elements of "input".
  y_{i} = \log_{10} (x_{i})

Parameters:
      input (Tensor) -- the input tensor.
Keyword Arguments:
      out (Tensor, optional) -- the output tensor.
Example:
  >>> a = torch.rand(5)
  >>> a
  tensor([ 0.5224,  0.9354,  0.7257,  0.1301,  0.2251])


  >>> torch.log10(a)
  tensor([-0.2820, -0.0290, -0.1392, -0.8857, -0.6476])
torch.flatten
torch.flatten(input, start_dim=0, end_dim=- 1) -> Tensor
Flattens "input" by reshaping it into a one-dimensional tensor. If
   "start_dim" or "end_dim" are passed, only dimensions starting with
   "start_dim" and ending with "end_dim" are flattened. The order of
   elements in "input" is unchanged.
Unlike NumPy's flatten, which always copies input's data, this
   function may return the original object, a view, or copy. If no
   dimensions are flattened, then the original object "input" is
   returned. Otherwise, if input can be viewed as the flattened shape,
   then that view is returned. Finally, only if the input cannot be
   viewed as the flattened shape is input's data copied. See
   "torch.Tensor.view()" for details on when a view will be returned.
Note:
 Flattening a zero-dimensional tensor will return a one-
 dimensional view.

Parameters:
      * input (Tensor) -- the input tensor.
  * **start_dim** (*int*) -- the first dim to flatten
end_dim (int) -- the last dim to flatten

Example:
  >>> t = torch.tensor([[[1, 2],
  ...                    [3, 4]],
  ...                   [[5, 6],
  ...                    [7, 8]]])
  >>> torch.flatten(t)
  tensor([1, 2, 3, 4, 5, 6, 7, 8])
  >>> torch.flatten(t, start_dim=1)
  tensor([[1, 2, 3, 4],
          [5, 6, 7, 8]])
torch.nn.utils.clip_grad_norm_
torch.nn.utils.clip_grad_norm_(parameters, max_norm, norm_type=2.0, error_if_nonfinite=False, foreach=None)
Clips gradient norm of an iterable of parameters.
The norm is computed over all gradients together, as if they were
   concatenated into a single vector. Gradients are modified in-place.
Parameters:
      * parameters (Iterable[Tensor] or Tensor) -- an
        iterable of Tensors or a single Tensor that will have
        gradients normalized
  * **max_norm** (*float*) -- max norm of the gradients

  * **norm_type** (*float*) -- type of the used p-norm. Can be
    "'inf'" for infinity norm.

  * **error_if_nonfinite** (*bool*) -- if True, an error is thrown
    if the total norm of the gradients from "parameters" is "nan",
    "inf", or "-inf". Default: False (will switch to True in the
    future)

  * **foreach** (*bool*) -- use the faster foreach-based
torch.view_as_complex
torch.view_as_complex(input) -> Tensor
Returns a view of "input" as a complex tensor. For an input complex
   tensor of "size" m1, m2, \dots, mi, 2, this function returns a new
   complex tensor of "size" m1, m2, \dots, mi where the last dimension
   of the input tensor is expected to represent the real and imaginary
   components of complex numbers.
Warning:
 "view_as_complex()" is only supported for tensors with
 "torch.dtype" "torch.float64" and "torch.float32".  The input is
 expected to have the last dimension of "size" 2. In addition, the
 tensor must have a *stride* of 1 for its last dimension. The
 strides of all other dimensions must be even numbers.

Parameters:
      input (Tensor) -- the input tensor.
Example:
  >>> x=torch.randn(4, 2)
  >>> x
  tensor([[ 1.6116, -0.5772],
          [-1.4606, -0.9120],
          [ 0.0786, -1.7497],
          [-0.6561, -1.6623]])