shrinath-suresh/blogs-docs-splitted huggingface dataset:
Yields:
         Module -- a module in the network
  Return type:
     *Iterator*[*Module*]

  Note:

    Duplicate modules are returned only once. In the following
    example, "l" will be returned only once.

  Example:

     >>> l = nn.Linear(2, 2)
     >>> net = nn.Sequential(l, l)
     >>> for idx, m in enumerate(net.modules()):
     ...     print(idx, '->', m)

     0 -> Sequential(
       (0): Linear(in_features=2, out_features=2, bias=True)
       (1): Linear(in_features=2, out_features=2, bias=True)
     )
     1 -> Linear(in_features=2, out_features=2, bias=True)

named_buffers(prefix='', recurse=True, remove_duplicate=True)
  Returns an iterator over module buffers, yielding both the name
  of the buffer as well as the buffer itself.

  Parameters:
     * **prefix** (*str*) -- prefix to prepend to all buffer
       names.

     * **recurse** (*bool**, **optional*) -- if True, then yields
buffers of this module and all submodules. Otherwise,
           yields only buffers that are direct members of this module.
           Defaults to True.
     * **remove_duplicate** (*bool**, **optional*) -- whether to
       remove the duplicated buffers in the result. Defaults to
       True.

  Yields:
     *(str, torch.Tensor)* -- Tuple containing the name and buffer

  Return type:
     *Iterator*[*Tuple*[str, *Tensor*]]

  Example:

     >>> for name, buf in self.named_buffers():
     >>>     if name in ['running_var']:
     >>>         print(buf.size())

named_children()
  Returns an iterator over immediate children modules, yielding
  both the name of the module as well as the module itself.

  Yields:
     *(str, Module)* -- Tuple containing a name and child module

  Return type:
     *Iterator*[*Tuple*[str, *Module*]]

  Example:

     >>> for name, module in model.named_children():
if name in ['conv4', 'conv5']:
     >>>         print(module)




named_modules(memo=None, prefix='', remove_duplicate=True)
  Returns an iterator over all modules in the network, yielding
  both the name of the module as well as the module itself.

  Parameters:
     * **memo** (*Optional**[**Set**[**Module**]**]*) -- a memo to
       store the set of modules already added to the result

     * **prefix** (*str*) -- a prefix that will be added to the
       name of the module

     * **remove_duplicate** (*bool*) -- whether to remove the
       duplicated module instances in the result or not

  Yields:
     *(str, Module)* -- Tuple of name and module

  Note:

    Duplicate modules are returned only once. In the following
    example, "l" will be returned only once.

  Example:

     >>> l = nn.Linear(2, 2)
     >>> net = nn.Sequential(l, l)
     >>> for idx, m in enumerate(net.named_modules()):
this module.
  This method sets the parameters' "requires_grad" attributes in-
  place.

  This method is helpful for freezing part of the module for
  finetuning or training parts of a model individually (e.g., GAN
  training).

  See Locally disabling gradient computation for a comparison
  between *.requires_grad_()* and several similar mechanisms that
  may be confused with it.

  Parameters:
     **requires_grad** (*bool*) -- whether autograd should record
     operations on parameters in this module. Default: "True".

  Returns:
     self

  Return type:
     Module

set_extra_state(state)
  This function is called from "load_state_dict()" to handle any
  extra state found within the *state_dict*. Implement this
  function and a corresponding "get_extra_state()" for your module
  if you need to store extra state within its *state_dict*.

  Parameters:
Parameters:
         state (dict) -- Extra state from the state_dict
share_memory()
  See "torch.Tensor.share_memory_()"

  Return type:
     *T*

state_dict(, destination: T_destination, prefix: str = '', keep_vars: bool = False) -> T_destination
   state_dict(, prefix: str = '', keep_vars: bool = False) -> Dict[str, Any]
  Returns a dictionary containing references to the whole state of
  the module.

  Both parameters and persistent buffers (e.g. running averages)
  are included. Keys are corresponding parameter and buffer names.
  Parameters and buffers set to "None" are not included.

  Note:

    The returned object is a shallow copy. It contains references
    to the module's parameters and buffers.

  Warning:

    Currently "state_dict()" also accepts positional arguments for
    "destination", "prefix" and "keep_vars" in order. However,
    this is being deprecated and keyword arguments will be
enforced in future releases.
  Warning:

    Please avoid the use of argument "destination" as it is not
    designed for end-users.

  Parameters:
     * **destination** (*dict**, **optional*) -- If provided, the
       state of module will be updated into the dict and the same
       object is returned. Otherwise, an "OrderedDict" will be
       created and returned. Default: "None".

     * **prefix** (*str**, **optional*) -- a prefix added to
       parameter and buffer names to compose the keys in
       state_dict. Default: "''".

     * **keep_vars** (*bool**, **optional*) -- by default the
       "Tensor" s returned in the state dict are detached from
       autograd. If it's set to "True", detaching will not be
       performed. Default: "False".

  Returns:
     a dictionary containing a whole state of the module

  Return type:
     dict

  Example:

     >>> module.state_dict().keys()
module.state_dict().keys()
         ['bias', 'weight']



to(device: Optional[Union[int, device]] = ..., dtype: Optional[Union[dtype, str]] = ..., non_blocking: bool = ...) -> T
   to(dtype: Union[dtype, str], non_blocking: bool = ...) -> T
   to(tensor: Tensor, non_blocking: bool = ...) -> T
  Moves and/or casts the parameters and buffers.

  This can be called as

  to(device=None, dtype=None, non_blocking=False)

  to(dtype, non_blocking=False)

  to(tensor, non_blocking=False)

  to(memory_format=torch.channels_last)

  Its signature is similar to "torch.Tensor.to()", but only
  accepts floating point or complex "dtype"s. In addition, this
  method will only cast the floating point or complex parameters
  and buffers to "dtype" (if given). The integral parameters and
  buffers will be moved "device", if that is given, but with
  dtypes unchanged. When "non_blocking" is set, it tries to
convert/move asynchronously with respect to the host if
      possible, e.g., moving CPU Tensors with pinned memory to CUDA
      devices.
  See below for examples.

  Note:

    This method modifies the module in-place.

  Parameters:
     * **device** ("torch.device") -- the desired device of the
       parameters and buffers in this module

     * **dtype** ("torch.dtype") -- the desired floating point or
       complex dtype of the parameters and buffers in this module

     * **tensor** (*torch.Tensor*) -- Tensor whose dtype and
       device are the desired dtype and device for all parameters
       and buffers in this module

     * **memory_format** ("torch.memory_format") -- the desired
       memory format for 4D parameters and buffers in this module
       (keyword only argument)

  Returns:
     self

  Return type:
     Module

  Examples:

     >>> linear = nn.Linear(2, 2)
     >>> linear.weight
linear.weight
         Parameter containing:
         tensor([[ 0.1913, -0.3420],
                 [-0.5113, -0.2325]])
         >>> linear.to(torch.double)
         Linear(in_features=2, out_features=2, bias=True)
         >>> linear.weight
         Parameter containing:
         tensor([[ 0.1913, -0.3420],
                 [-0.5113, -0.2325]], dtype=torch.float64)
         >>> gpu1 = torch.device("cuda:1")
         >>> linear.to(gpu1, dtype=torch.half, non_blocking=True)
         Linear(in_features=2, out_features=2, bias=True)
         >>> linear.weight
         Parameter containing:
         tensor([[ 0.1914, -0.3420],
                 [-0.5112, -0.2324]], dtype=torch.float16, device='cuda:1')
         >>> cpu = torch.device("cpu")
         >>> linear.to(cpu)
         Linear(in_features=2, out_features=2, bias=True)
         >>> linear.weight
         Parameter containing:
         tensor([[ 0.1914, -0.3420],
                 [-0.5112, -0.2324]], dtype=torch.float16)
linear = nn.Linear(2, 2, bias=None).to(torch.cdouble)
         >>> linear.weight
         Parameter containing:
         tensor([[ 0.3741+0.j,  0.2382+0.j],
                 [ 0.5593+0.j, -0.4443+0.j]], dtype=torch.complex128)
         >>> linear(torch.ones(3, 2, dtype=torch.cdouble))
         tensor([[0.6122+0.j, 0.1150+0.j],
                 [0.6122+0.j, 0.1150+0.j],
                 [0.6122+0.j, 0.1150+0.j]], dtype=torch.complex128)



to_empty(*, device)
  Moves the parameters and buffers to the specified device without
  copying storage.

  Parameters:
     **device** ("torch.device") -- The desired device of the
     parameters and buffers in this module.

  Returns:
     self

  Return type:
     Module

train(mode=True)
  Sets the module in training mode.

  This has any effect only on certain modules. See documentations
  of particular modules for details of their behaviors in
training/evaluation mode, if they are affected, e.g. "Dropout",
      "BatchNorm", etc.
  Parameters:
     **mode** (*bool*) -- whether to set training mode ("True") or
     evaluation mode ("False"). Default: "True".

  Returns:
     self

  Return type:
     Module

type(dst_type)
  Casts all parameters and buffers to "dst_type".

  Note:

    This method modifies the module in-place.

  Parameters:
     **dst_type** (*type** or **string*) -- the desired type

  Returns:
     self

  Return type:
     Module

xpu(device=None)
  Moves all model parameters and buffers to the XPU.

  This also makes associated parameters and buffers different
  objects. So it should be called before constructing optimizer if
  the module will live on XPU while being optimized.

  Note:

    This method modifies the module in-place.

  Parameters:
     **device** (*int**, **optional*) -- if specified, all
parameters will be copied to that device
  Returns:
     self

  Return type:
     Module

zero_grad(set_to_none=False)
  Sets gradients of all model parameters to zero. See similar
  function under "torch.optim.Optimizer" for more context.

  Parameters:
     **set_to_none** (*bool*) -- instead of setting to zero, set
     the grads to None. See "torch.optim.Optimizer.zero_grad()"
     for details.
torch.meshgrid
torch.meshgrid(*tensors, indexing=None)
Creates grids of coordinates specified by the 1D inputs in
   attr:tensors.
This is helpful when you want to visualize data over some range of
   inputs. See below for a plotting example.
Given N 1D tensors T_0 \ldots T_{N-1} as inputs with corresponding
   sizes S_0 \ldots S_{N-1}, this creates N N-dimensional tensors G_0
   \ldots G_{N-1}, each with shape (S_0, ..., S_{N-1}) where the
   output G_i is constructed by expanding T_i to the result shape.
Note:
 0D inputs are treated equivalently to 1D inputs of a single
 element.

Warning:
 *torch.meshgrid(*tensors)* currently has the same behavior as
 calling *numpy.meshgrid(*arrays, indexing='ij')*.In the future
 *torch.meshgrid* will transition to *indexing='xy'* as the
 default.https://github.com/pytorch/pytorch/issues/50276 tracks
 this issue with the goal of migrating to NumPy's behavior.

See also:
See also:
 "torch.cartesian_prod()" has the same effect but it collects the
 data in a tensor of vectors.

Parameters:
      * tensors (list of Tensor) -- list of scalars or 1
        dimensional tensors. Scalars will be treated as tensors of
        size (1,) automatically
  * **indexing** (*Optional**[**str**]*) --

    (str, optional): the indexing mode, either "xy" or "ij",
    defaults to "ij". See warning for future changes.

    If "xy" is selected, the first dimension corresponds to the
    cardinality of the second input and the second dimension
    corresponds to the cardinality of the first input.

    If "ij" is selected, the dimensions are in the same order as
    the cardinality of the inputs.

Returns:
      If the input has N tensors of size S_0 \ldots S_{N-1}`, then the
      output will also have N tensors, where each tensor is of shape
      (S_0, ..., S_{N-1}).
Return type:
      seq (sequence of Tensors)
Example:
seq (sequence of Tensors)
Example:
  >>> x = torch.tensor([1, 2, 3])
  >>> y = torch.tensor([4, 5, 6])

  Observe the element-wise pairings across the grid, (1, 4),
  (1, 5), ..., (3, 6). This is the same thing as the
  cartesian product.
  >>> grid_x, grid_y = torch.meshgrid(x, y, indexing='ij')
  >>> grid_x
  tensor([[1, 1, 1],
          [2, 2, 2],
          [3, 3, 3]])
  >>> grid_y
  tensor([[4, 5, 6],
          [4, 5, 6],
          [4, 5, 6]])

  This correspondence can be seen when these grids are
  stacked properly.
  >>> torch.equal(torch.cat(tuple(torch.dstack([grid_x, grid_y]))),
  ...             torch.cartesian_prod(x, y))
  True

  `torch.meshgrid` is commonly used to produce a grid for
  plotting.
  >>> import matplotlib.pyplot as plt
  >>> xs = torch.linspace(-5, 5, steps=100)
  >>> ys = torch.linspace(-5, 5, steps=100)
  >>> x, y = torch.meshgrid(xs, ys, indexing='xy')
torch.nn.functional.dropout3d
torch.nn.functional.dropout3d(input, p=0.5, training=True, inplace=False)
Randomly zero out entire channels (a channel is a 3D feature map,
   e.g., the j-th channel of the i-th sample in the batched input is a
   3D tensor \text{input}[i, j]) of the input tensor). Each channel
   will be zeroed out independently on every forward call with
   probability "p" using samples from a Bernoulli distribution.
See "Dropout3d" for details.
Parameters:
      * p (float) -- probability of a channel to be zeroed.
        Default: 0.5
  * **training** (*bool*) -- apply dropout if is "True". Default:
    "True"

  * **inplace** (*bool*) -- If set to "True", will do this
    operation in-place. Default: "False"

Return type:
      Tensor
MSELoss
class torch.nn.MSELoss(size_average=None, reduce=None, reduction='mean')
Creates a criterion that measures the mean squared error (squared
   L2 norm) between each element in the input x and target y.
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 = \left( x_n
  - y_n \right)^2,

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}

x and y are tensors of arbitrary shapes with a total of n elements
   each.
The mean operation still operates over all the elements, and
   divides by n.
The division by n can be avoided if one sets "reduction = 'sum'".
Parameters:
      * 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.

Examples:
  >>> loss = nn.MSELoss()
  >>> input = torch.randn(3, 5, requires_grad=True)
  >>> target = torch.randn(3, 5)
  >>> output = loss(input, target)
  >>> output.backward()
torch.linalg.eigh
torch.linalg.eigh(A, UPLO='L', *, out=None)
Computes the eigenvalue decomposition of a complex Hermitian or
   real symmetric matrix.
Letting \mathbb{K} be \mathbb{R} or \mathbb{C}, the eigenvalue
   decomposition of a complex Hermitian or real symmetric matrix A
   \in \mathbb{K}^{n \times n} is defined as
  A = Q \operatorname{diag}(\Lambda) Q^{\text{H}}\mathrlap{\qquad
  Q \in \mathbb{K}^{n \times n}, \Lambda \in \mathbb{R}^n}

where Q^{\text{H}} is the conjugate transpose when Q is complex,
   and the transpose when Q is real-valued. Q is orthogonal in the
   real case and unitary in the complex case.
Supports input of float, double, cfloat and cdouble dtypes. Also
   supports batches of matrices, and if "A" is a batch of matrices
   then the output has the same batch dimensions.
"A" is assumed to be Hermitian (resp. symmetric), but this is not
   checked internally, instead:
checked internally, instead:


If "UPLO"= 'L' (default), only the lower triangular part of the
     matrix is used in the computation.


If "UPLO"= 'U', only the upper triangular part of the matrix is
     used.


The eigenvalues are returned in ascending order.
Note:
 When inputs are on a CUDA device, this function synchronizes that
 device with the CPU.

Note:
 The eigenvalues of real symmetric or complex Hermitian matrices
 are always real.

Warning:
 The eigenvectors of a symmetric matrix are not unique, nor are
 they continuous with respect to "A". Due to this lack of
 uniqueness, different hardware and software may compute different
 eigenvectors.This non-uniqueness is caused by the fact that
 multiplying an eigenvector by *-1* in the real case or by e^{i
 \phi}, \phi \in \mathbb{R} in the complex case produces another
 set of valid eigenvectors of the matrix. For this reason, the
loss function shall not depend on the phase of the eigenvectors,
     as this quantity is not well-defined. This is checked for complex
     inputs when computing the gradients of this function. As such,
     when inputs are complex and are on a CUDA device, the computation
     of the gradients of this function synchronizes that device with
     the CPU.
Warning:
 Gradients computed using the *eigenvectors* tensor will only be
 finite when "A" has distinct eigenvalues. Furthermore, if the
 distance between any two eigenvalues is close to zero, the
 gradient will be numerically unstable, as it depends on the
 eigenvalues \lambda_i through the computation of \frac{1}{\min_{i
 \neq j} \lambda_i - \lambda_j}.

See also:
 "torch.linalg.eigvalsh()" computes only the eigenvalues of a
 Hermitian matrix. Unlike "torch.linalg.eigh()", the gradients of
 "eigvalsh()" are always numerically stable.

 "torch.linalg.cholesky()" for a different decomposition of a
Hermitian matrix. The Cholesky decomposition gives less
     information about the matrix but is much faster to compute than
     the eigenvalue decomposition.
 "torch.linalg.eig()" for a (slower) function that computes the
 eigenvalue decomposition of a not necessarily Hermitian square
 matrix.

 "torch.linalg.svd()" for a (slower) function that computes the
 more general SVD decomposition of matrices of any shape.

 "torch.linalg.qr()" for another (much faster) decomposition that
 works on general matrices.

Parameters:
      * A (Tensor) -- tensor of shape (, n, n)* where *** is
        zero or more batch dimensions consisting of symmetric or
        Hermitian matrices.
  * **UPLO** (*'L'**, **'U'**, **optional*) -- controls whether to
    use the upper or lower triangular part of "A" in the
    computations. Default: *'L'*.

Keyword Arguments:
      out (tuple, optional) -- output tuple of two tensors.
Ignored if None. Default: None.
Returns:
      A named tuple (eigenvalues, eigenvectors) which corresponds to
      \Lambda and Q above.
  *eigenvalues* will always be real-valued, even when "A" is
  complex. It will also be ordered in ascending order.

  *eigenvectors* will have the same dtype as "A" and will contain
  the eigenvectors as its columns.

Examples::
      >>> A = torch.randn(2, 2, dtype=torch.complex128)
      >>> A = A + A.T.conj()  # creates a Hermitian matrix
      >>> A
      tensor([[2.9228+0.0000j, 0.2029-0.0862j],
              [0.2029+0.0862j, 0.3464+0.0000j]], dtype=torch.complex128)
      >>> L, Q = torch.linalg.eigh(A)
      >>> L
      tensor([0.3277, 2.9415], dtype=torch.float64)
      >>> Q
      tensor([[-0.0846+-0.0000j, -0.9964+0.0000j],
              [ 0.9170+0.3898j, -0.0779-0.0331j]], dtype=torch.complex128)
      >>> torch.dist(Q @ torch.diag(L.cdouble()) @ Q.T.conj(), A)
      tensor(6.1062e-16, dtype=torch.float64)
tensor(6.1062e-16, dtype=torch.float64)
  >>> A = torch.randn(3, 2, 2, dtype=torch.float64)
  >>> A = A + A.mT  # creates a batch of symmetric matrices
  >>> L, Q = torch.linalg.eigh(A)
  >>> torch.dist(Q @ torch.diag_embed(L) @ Q.mH, A)
  tensor(1.5423e-15, dtype=torch.float64)
torch.autograd.forward_ad.unpack_dual
torch.autograd.forward_ad.unpack_dual(tensor, *, level=None)
Unpacks a "dual tensor" to get both its Tensor value and its
   forward AD gradient. The result is a namedtuple "(primal, tangent)"
   where "primal" is a view of "tensor"'s primal and "tangent" is
   "tensor"'s tangent as-is. Neither of these tensors can be dual
   tensor of level "level".
This function is backward differentiable.
Example:
  >>> with dual_level():
  ...     inp = make_dual(x, x_t)
  ...     out = f(inp)
  ...     y, jvp = unpack_dual(out)
  ...     jvp = unpack_dual(out).tangent

Please see the forward-mode AD tutorial for detailed steps on how
   to use this API.
torch.nn.functional.normalize
torch.nn.functional.normalize(input, p=2.0, dim=1, eps=1e-12, out=None)
Performs L_p normalization of inputs over specified dimension.
For a tensor "input" of sizes (n_0, ..., n_{dim}, ..., n_k), each
   n_{dim} -element vector v along dimension "dim" is transformed as
  v = \frac{v}{\max(\lVert v \rVert_p, \epsilon)}.

With the default arguments it uses the Euclidean norm over vectors
   along dimension 1 for normalization.
Parameters:
      * input (Tensor) -- input tensor of any shape
  * **p** (*float*) -- the exponent value in the norm formulation.
    Default: 2

  * **dim** (*int*) -- the dimension to reduce. Default: 1

  * **eps** (*float*) -- small value to avoid division by zero.
    Default: 1e-12

  * **out** (*Tensor**, **optional*) -- the output tensor. If
    "out" is used, this operation won't be differentiable.

Return type:
      Tensor
torch.nn.functional.conv3d
torch.nn.functional.conv3d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1) -> Tensor
Applies a 3D convolution over an input image composed of several
   input planes.
This operator supports TensorFloat32.
See "Conv3d" for details and output shape.
Note:
 In some circumstances when given tensors on a CUDA device and
 using CuDNN, this operator may select a nondeterministic
 algorithm to increase performance. If this is undesirable, you
 can try to make the operation deterministic (potentially at a
 performance cost) by setting "torch.backends.cudnn.deterministic
 = True". See Reproducibility for more information.

Note:
 This operator supports complex data types i.e. "complex32,
 complex64, complex128".

Parameters:
      * input -- input tensor of shape (\text{minibatch} ,
        \text{in_channels} , iT , iH , iW)