§
    ŠŠtjÔ
  ã                  óV   — d dl mZ d dlZd dlmZ dgZ ed¦  «        dd„¦   «         ZdS )é    )ÚannotationsN)Ú
exposed_inÚ	rearrangez
torch.funcÚtensorú<torch.Tensor | list[torch.Tensor] | tuple[torch.Tensor, ...]ÚpatternÚstrÚaxes_lengthsÚintÚreturnútorch.Tensorc                óž   — t          | t          j        ¦  «        st          j        | ¦  «        } ddlm}  || j        |fi |¤Ž} || ¦  «        S )aç  A native implementation of `einops.rearrange`, a reader-friendly smart element reordering for multidimensional
    tensors. This operation includes functionality of transpose (axes permutation), reshape (view), squeeze, unsqueeze,
    stack, concatenate and other operations.

    See: https://einops.rocks/api/rearrange/

    Args:
        tensor (Tensor or sequence of Tensor): the tensor(s) to rearrange
        pattern (str): the rearrangement pattern
        axes_lengths (int): any additional length specifications for dimensions

    Returns:
        Tensor: the rearranged tensor

    Examples:
        >>> from torch.func import rearrange
        >>> # suppose we have a set of 32 images in "h w c" format (height-width-channel)
        >>> images = torch.randn((32, 30, 40, 3))

        >>> # stack along first (batch) axis, output is a single array
        >>> rearrange(images, "b h w c -> b h w c").shape
        torch.Size([32, 30, 40, 3])

        >>> # concatenate images along height (vertical axis), 960 = 32 * 30
        >>> rearrange(images, "b h w c -> (b h) w c").shape
        torch.Size([960, 40, 3])

        >>> # concatenated images along horizontal axis, 1280 = 32 * 40
        >>> rearrange(images, "b h w c -> h (b w) c").shape
        torch.Size([30, 1280, 3])

        >>> # reordered axes to "b c h w" format for deep learning
        >>> rearrange(images, "b h w c -> b c h w").shape
        torch.Size([32, 3, 30, 40])

        >>> # flattened each image into a vector, 3600 = 30 * 40 * 3
        >>> rearrange(images, "b h w c -> b (c h w)").shape
        torch.Size([32, 3600])

        >>> # split each image into 4 smaller (top-left, top-right, bottom-left, bottom-right), 128 = 32 * 2 * 2
        >>> rearrange(images, "b (h1 h) (w1 w) c -> (b h1 w1) h w c", h1=2, w1=2).shape
        torch.Size([128, 15, 20, 3])

        >>> # space-to-depth operation
        >>> rearrange(images, "b (h h1) (w w1) c -> b h w (c h1 w1)", h1=2, w1=2).shape
        torch.Size([32, 15, 20, 12])
    r   )Ú_create_rearrange_callable)Ú
isinstanceÚtorchÚTensorÚstackÚfunctorch.einops.rearranger   Úndim)r   r   r
   r   Úrearrange_callables        úU/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/torch/_functorch/einops.pyr   r   
   sw   € õj �f�eœlÑ+Ô+ð %Ý”˜VÑ$Ô$ˆð FÐEÐEÐEÐEÐEà3Ð3ØŒ�Wðð Ø ,ðð Ðð Ð˜fÑ%Ô%Ð%ó    )r   r   r   r	   r
   r   r   r   )Ú
__future__r   r   Útorch._functorch.utilsr   Ú__all__r   © r   r   ú<module>r      sp   ðØ "Ð "Ð "Ð "Ð "Ð "à €€€Ø -Ð -Ð -Ð -Ð -Ð -ð ˆ-€ð €ˆLÑÔð?&ð ?&ð ?&ñ Ôð?&ð ?&ð ?&r   