§
    “©ºj  ã                   óf   — d Z ddlmZ ddlZddlmZ ddedeeeef         ded	e	eef         fd
„Z
dS )z Utilities to describe gradients.é    )ÚUnionN)ÚModuleú/ÚmoduleÚ	norm_typeÚgroup_separatorÚreturnc                 ó<  ‡‡— t          ‰¦  «        Š‰dk    rt          d‰› �¦  «        ‚ˆˆfd„|                      ¦   «         D ¦   «         }|rOt          j        t          |                     ¦   «         ¦  «        ¦  «                             ‰¦  «        }||d‰› d�<   |S )aÒ  Compute each parameter's gradient's norm and their overall norm.

    The overall norm is computed over all gradients together, as if they
    were concatenated into a single vector.

    Args:
        module: :class:`torch.nn.Module` to inspect.
        norm_type: The type of the used p-norm, cast to float if necessary.
            Can be ``'inf'`` for infinity norm.
        group_separator: The separator string used by the logger to group
            the gradients norms in their own subfolder instead of the logs one.

    Return:
        norms: The dictionary of p-norms of each parameter's gradient and
            a special entry for the total p-norm of the gradients viewed
            as a single vector.

    r   zD`norm_type` must be a positive number or 'inf' (infinity norm). Got c                 ót   •— i | ]4\  }}|j         ®d‰› d‰› |› �|j         j                             ‰¦  «        “Œ5S )NÚgrad_Ú_norm)ÚgradÚdataÚnorm)Ú.0ÚnameÚpr   r   s      €€úq/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/pytorch_lightning/utilities/grads.pyú
<dictcomp>zgrad_norm.<locals>.<dictcomp>-   sX   ø€ ð ð ð áˆD�!ØŒ6Ðð 	8�	Ð7Ð7 Ð7°Ð7Ð7¸¼¼×9IÒ9IÈ)Ñ9TÔ9TàÐÐó    r   Ú_norm_total)ÚfloatÚ
ValueErrorÚnamed_parametersÚtorchÚtensorÚlistÚvaluesr   )r   r   r   ÚnormsÚ
total_norms    ``  r   Ú	grad_normr!      s¿   øø€ õ& �iÑ Ô €IØ�A‚~€~ÝÐkÐ`iÐkÐkÑlÔlÐlðð ð ð ð à×.Ò.Ñ0Ô0ðñ ô €Eð
 ð ;Ý”\¥$ u§|¢|¡~¤~Ñ"6Ô"6Ñ7Ô7×<Ò<¸YÑGÔGˆ
Ø0:ˆÐ,�iÐ,Ð,Ð,Ñ-Ø€Lr   )r   )Ú__doc__Útypingr   r   Útorch.nnr   r   ÚintÚstrÚdictr!   © r   r   ú<module>r)      s’   ðð 'Ð &à Ð Ð Ð Ð Ð à €€€Ø Ð Ð Ð Ð Ð ðð �fð ¨¨u°c¸3¨Ô)?ð ÐRUð Ð`dÐehÐjoÐeoÔ`pð ð ð ð ð ð r   