§
    Ó˜ºh¡  ã                   óv   — d dl mZ d dlmZ d dlmZ ddlmZ ddgZ G d„ de¦  «        Z	 G d	„ de¦  «        Z
d
S )é    )ÚUnion)ÚTensor)Ú_sizeé   )ÚModuleÚFlattenÚ	Unflattenc                   ól   ‡ — e Zd ZU dZddgZeed<   eed<   ddededdfˆ fd„Zd	edefd
„Z	de
fd„Zˆ xZS )r   a¯  
    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_dimr   éÿÿÿÿÚreturnNc                 ód   •— t          ¦   «                              ¦   «          || _        || _        d S ©N)ÚsuperÚ__init__r   r   )Úselfr   r   Ú	__class__s      €ú`/var/www/html/services/rag-service/venv/lib/python3.11/site-packages/torch/nn/modules/flatten.pyr   zFlatten.__init__/   s+   ø€ Ý‰Œ×ÒÑÔÐØ"ˆŒØˆŒˆˆó    Úinputc                 óB   — |                      | j        | j        ¦  «        S r   )Úflattenr   r   ©r   r   s     r   ÚforwardzFlatten.forward4   s   € Ø�}Š}˜Tœ^¨T¬\Ñ:Ô:Ð:r   c                 ó&   — d| j         › d| j        › �S )Nz
start_dim=z
, end_dim=)r   r   ©r   s    r   Ú
extra_reprzFlatten.extra_repr7   s   € ØD˜DœNÐDÐD°d´lÐDÐDÐDr   )r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__constants__ÚintÚ__annotations__r   r   r   Ústrr   Ú__classcell__©r   s   @r   r   r      sÇ   ø€ € € € € € ðð ð: ! )Ð,€MØ€N€N�NØ€L€L�Lðð  #ð °Cð Àð ð ð ð ð ð ð
;˜Vð ;¨ð ;ð ;ð ;ð ;ðE˜Cð Eð Eð Eð Eð Eð Eð Eð Er   c                   óÖ   ‡ — e Zd ZU dZeeeef                  ZddgZe	eef         e
d<   e	eef         e
d<   de	eef         de	eef         ddfˆ fd„Zd„ Zd„ Zd	edefd
„Zdefd„Zˆ xZS )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          ¦   «                              ¦   «          t          |t          ¦  «        r|                      |¦  «         n:t          |t
          ¦  «        r|                      |¦  «         nt          d¦  «        ‚|| _        || _	        d S )Nz'invalid argument type for dim parameter)
r   r   Ú
isinstancer$   Ú_require_tuple_intr&   Ú_require_tuple_tupleÚ	TypeErrorr*   r+   )r   r*   r+   r   s      €r   r   zUnflatten.__init__p   s•   ø€ õ 	‰Œ×ÒÑÔÐå�c�3ÑÔð 	GØ×#Ò#Ð$4Ñ5Ô5Ð5Ð5Ý˜�SÑ!Ô!ð 	GØ×%Ò%Ð&6Ñ7Ô7Ð7Ð7åÐEÑFÔFÐFàˆŒØ 0ˆÔÐÐr   c                 ó&  — t          |t          ¦  «        rVt          |¦  «        D ]D\  }}t          |t          ¦  «        s*t          ddt	          |¦  «        j        › d|› �z   ¦  «        ‚ŒEd S t          ddt	          |¦  «        j        › �z   ¦  «        ‚)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 )r-   ÚtupleÚ	enumerater0   Útyper   ©r   r   ÚidxÚelems       r   r/   zUnflatten._require_tuple_tuple   s³   € Ý�e�UÑ#Ô#ð 	Ý& uÑ-Ô-ð ð ‘	��TÝ! $­Ñ.Ô.ð Ý#ØDØYµt¸D±z´zÔ7JÐYÐYÐTWÐYÐYñZñô ð ðð
 ˆFÝØ:Ø6¥ U¡¤Ô 4Ð6Ð6ñ7ñ
ô 
ð 	
r   c                 ó.  — t          |t          t          f¦  «        rVt          |¦  «        D ]D\  }}t          |t          ¦  «        s*t          ddt          |¦  «        j        › d|› �z   ¦  «        ‚ŒEd S t          dt          |¦  «        j        › �¦  «        ‚)Nz(unflattened_size must be tuple of ints, r2   r3   z9unflattened_size must be a tuple of ints, but found type )r-   r4   Úlistr5   r$   r0   r6   r   r7   s       r   r.   zUnflatten._require_tuple_int�   s¯   € Ý�e�e¥T˜]Ñ+Ô+ð 	Ý& uÑ-Ô-ð ð ‘	��TÝ! $­Ñ,Ô,ð Ý#ØBØYµt¸D±z´zÔ7JÐYÐYÐTWÐYÐYñZñô ð ðð
 ˆFÝØ^ÍÈUÉÌÔH\Ð^Ð^ñ
ô 
ð 	
r   r   c                 óB   — |                      | j        | j        ¦  «        S r   )Ú	unflattenr*   r+   r   s     r   r   zUnflatten.forwardš   s   € Ø�Š˜tœx¨Ô)>Ñ?Ô?Ð?r   c                 ó&   — d| j         › d| j        › �S )Nzdim=z, unflattened_size=)r*   r+   r   s    r   r   zUnflatten.extra_repr�   s   € ØJ�d”hÐJÐJ°4Ô3HÐJÐJÐJr   )r   r    r!   r"   r4   r&   r$   Ú
NamedShaper#   r   r%   r   r   r/   r.   r   r   r   r'   r(   s   @r   r	   r	   ;   s'  ø€ € € € € € ð,ð ,ð\ �u˜S #˜X”Ô'€JàÐ.Ð/€MØ	ˆs�CˆxŒÐÐÑØ˜E :Ð-Ô.Ð.Ð.Ñ.ð1Ø˜˜c˜”?ð1Ø6;¸EÀ:Ð<MÔ6Nð1à	ð1ð 1ð 1ð 1ð 1ð 1ð
ð 
ð 
ð
ð 
ð 
ð@˜Vð @¨ð @ð @ð @ð @ðK˜Cð Kð Kð Kð Kð Kð Kð Kð Kr   N)Útypingr   Útorchr   Útorch.typesr   Úmoduler   Ú__all__r   r	   © r   r   ú<module>rF      sÔ   ðà Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð ð �kÐ
"€ð+Eð +Eð +Eð +Eð +Eˆfñ +Eô +Eð +Eð\cKð cKð cKð cKð cK�ñ cKô cKð cKð cKð cKr   