ó
    !Eñi€  ã                   ó\   • S SK Jr  S SKJr  SSKJr  SS/r " S S\5      r " S S\5      rg	)
é    )ÚTensor)Ú_sizeé   )ÚModuleÚFlattenÚ	Unflattenc                   ó~   ^ • \ rS rSr% SrSS/r\\S'   \\S'   SS\S\SS4U 4S jjjrS\	S\	4S	 jr
S\4S
 jrSrU =r$ )r   é   aS  
Flattens a contiguous range of dims into a tensor.

For use with :class:`~nn.Sequential`, see :meth:`torch.flatten` for details.

Shape:
    - Input: :math:`(*, S_{\text{start}},..., S_{i}, ..., S_{\text{end}}, *)`,'
      where :math:`S_{i}` is the size at dimension :math:`i` and :math:`*` means any
      number of dimensions including none.
    - Output: :math:`(*, \prod_{i=\text{start}}^{\text{end}} S_{i}, *)`.

Args:
    start_dim: first dim to flatten (default = 1).
    end_dim: last dim to flatten (default = -1).

Examples::
    >>> input = torch.randn(32, 1, 5, 5)
    >>> # With default parameters
    >>> m = nn.Flatten()
    >>> output = m(input)
    >>> output.size()
    torch.Size([32, 25])
    >>> # With non-default parameters
    >>> m = nn.Flatten(0, 2)
    >>> output = m(input)
    >>> output.size()
    torch.Size([160, 5])
Ú	start_dimÚend_dimÚreturnNc                 ó:   >• [         TU ]  5         Xl        X l        g )N)ÚsuperÚ__init__r   r   )Úselfr   r   Ú	__class__s      €ÚU/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/nn/modules/flatten.pyr   ÚFlatten.__init__.   s   ø€ Ü‰ÑÔØ"ŒØ�ó    Úinputc                 óN   • UR                  U R                  U R                  5      $ ©z
Runs the forward pass.
)Úflattenr   r   ©r   r   s     r   ÚforwardÚFlatten.forward3   s   € ð �}‰}˜TŸ^™^¨T¯\©\Ó:Ð:r   c                 ó:   • SU R                    SU R                   3$ )ú1
Returns the extra representation of the module.
z
start_dim=z
, end_dim=)r   r   ©r   s    r   Ú
extra_reprÚFlatten.extra_repr9   s    € ð ˜DŸN™NÐ+¨:°d·l±l°^ÐDÐDr   )r   r   )r   éÿÿÿÿ)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__constants__ÚintÚ__annotations__r   r   r   Ústrr    Ú__static_attributes__Ú__classcell__©r   s   @r   r   r      sd   ø‡ ñð: ! )Ð,€MØƒNØƒLñ #ð °Cð À÷ ð ð
;˜Vð ;¨ô ;ðE˜C÷ Eò Er   c                   óº   ^ • \ rS rSr% Sr\\\\4      rSS/r	\\-  \
S'   \\-  \
S'   S\\-  S\\-  SS4U 4S jjrSS jrSS	 jrS
\S\4S jrS\4S jrSrU =r$ )r   é@   aã  
Unflattens a tensor dim expanding it to a desired shape. For use with :class:`~nn.Sequential`.

* :attr:`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.

* :attr:`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: :math:`(*, S_{\text{dim}}, *)`, where :math:`S_{\text{dim}}` is the size at
      dimension :attr:`dim` and :math:`*` means any number of dimensions including none.
    - Output: :math:`(*, U_1, ..., U_n, *)`, where :math:`U` = :attr:`unflattened_size` and
      :math:`\prod_{i=1}^n U_i = S_{\text{dim}}`.

Args:
    dim (Union[int, str]): Dimension to be 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])
ÚdimÚunflattened_sizer   Nc                 óì   >• [         TU ]  5         [        U[        5      (       a  U R	                  U5        O2[        U[
        5      (       a  U R                  U5        O[        S5      eXl        X l	        g )Nz'invalid argument type for dim parameter)
r   r   Ú
isinstancer)   Ú_require_tuple_intr+   Ú_require_tuple_tupleÚ	TypeErrorr1   r2   )r   r1   r2   r   s      €r   r   ÚUnflatten.__init__u   s]   ø€ Ü‰ÑÔä�cœ3×ÑØ×#Ñ#Ð$4Õ5Ü˜œS×!Ñ!Ø×%Ñ%Ð&6Õ7äÐEÓFÐFàŒØ 0Õr   c                 ó  • [        U[        5      (       aQ  [        U5       HA  u  p#[        U[        5      (       a  M  [        SS[	        U5      R
                   SU 3-   5      e   g [        SS[	        U5      R
                   3-   5      e)Nz*unflattened_size must be tuple of tuples, úbut found element of type ú at pos z,unflattened_size must be a tuple of tuples, zbut found type )r4   ÚtupleÚ	enumerater7   Útyper#   ©r   r   ÚidxÚelems       r   r6   ÚUnflatten._require_tuple_tuple‚   s�   € Ü�eœU×#Ñ#Ü& uÖ-‘	�Ü! $¬×.Ó.Ü#ØDØ6´t¸D³z×7JÑ7JÐ6KÈ8ÐTWÐSXÐYñZóð ñ .ð ÜØ:Ø¤ U£× 4Ñ 4Ð5Ð6ñ7ó
ð 	
r   c                 ó  • [        U[        [        45      (       aQ  [        U5       HA  u  p#[        U[        5      (       a  M  [        SS[        U5      R                   SU 3-   5      e   g [        S[        U5      R                   35      e)Nz(unflattened_size must be tuple of ints, r:   r;   z9unflattened_size must be a tuple of ints, but found type )r4   r<   Úlistr=   r)   r7   r>   r#   r?   s       r   r5   ÚUnflatten._require_tuple_int�   s‹   € Ü�eœe¤T˜]×+Ñ+Ü& uÖ-‘	�Ü! $¬×,Ó,Ü#ØBØ6´t¸D³z×7JÑ7JÐ6KÈ8ÐTWÐSXÐYñZóð ñ .ð ÜØGÌÈUË×H\ÑH\ÐG]Ð^ó
ð 	
r   r   c                 óN   • UR                  U R                  U R                  5      $ r   )Ú	unflattenr1   r2   r   s     r   r   ÚUnflatten.forward�   s   € ð �‰˜tŸx™x¨×)>Ñ)>Ó?Ð?r   c                 ó:   • SU R                    SU R                   3$ )r   zdim=z, unflattened_size=©r1   r2   r   s    r   r    ÚUnflatten.extra_repr£   s#   € ð �d—h‘h�ZÐ2°4×3HÑ3HÐ2IÐJÐJr   rJ   )r   N)r#   r$   r%   r&   r'   r<   r+   r)   Ú
NamedShaper(   r*   r   r   r6   r5   r   r   r    r,   r-   r.   s   @r   r   r   @   s”   ø‡ ñ,ð\ �u˜S #˜X‘Ñ'€JàÐ.Ð/€MØ	ˆs‰ƒNØ˜jÑ(Ó(ð1˜C #™Ið 1¸ÀÑ9Kð 1ÐPT÷ 1ô
ô
ð@˜Vð @¨ô @ðK˜C÷ Kò Kr   N)	Útorchr   Útorch.typesr   Úmoduler   Ú__all__r   r   © r   r   Ú<module>rR      s;   ðõ Ý å ð �kÐ
"€ô1Eˆfô 1EôhgK�õ gKr   