Ë
    ÿÍ:j  ã                   óX   — 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
y)z Utilities to describe gradients.é    )ÚUnionN)ÚModuleÚmoduleÚ	norm_typeÚgroup_separatorÚreturnc           	      óŽ  — t        |«      }|dk  rt        d|› �«      ‚| j                  «       D ��ci c]?  \  }}|j                  �.d|› d|› |› �|j                  j                  j                  |«      “ŒA }}}|rDt        j                  t        |j                  «       «      «      j                  |«      }||d|› d�<   |S c c}}w )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 Úgrad_Ú_normÚ_norm_total)
ÚfloatÚ
ValueErrorÚnamed_parametersÚgradÚdataÚnormÚtorchÚtensorÚlistÚvalues)r   r   r   ÚnameÚpÚnormsÚ
total_norms          úv/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/lightning/pytorch/utilities/grads.pyÚ	grad_normr      sÐ   € ô& �iÓ €IØ�A‚~ÜÐ_Ð`iÐ_jÐkÓlÐlð ×.Ñ.Ó0÷áˆD�!Ø�6‰6Ðð �	ˆ{˜% Ð0°°Ð7¸¿¹¿¹×9IÑ9IÈ)Ó9TÑTð€Eñ ñ
 Ü—\‘\¤$ u§|¡|£~Ó"6Ó7×<Ñ<¸YÓGˆ
Ø0:ˆ��i�[ Ð,Ñ-Ø€Lùós   ²AC)ú/)Ú__doc__Útypingr   r   Útorch.nnr   r   ÚintÚstrÚdictr   © ó    r   ú<module>r&      sM   ðñ 'å ã Ý ñ�fð ¨¨u°c¸3¨Ñ)?ð ÐRUð Ð`dÐehÐjoÐeoÑ`pô r%   