
    ~j                         S r SSKrSSKr\R                  " S\S9  \R
                  R                  SS5        SSKrSSKJ	r	  SSK
Jr  \R                  " 5         S r\S	:X  a  \" 5         gg)
a1  Torch reference of the Music3 flow VAE decoder.

Imports MiniMaxMusic3Vocoder from the reference project ../../diffusers.
Dumps a seeded random latent and the decoded audio for the GGML parity.
Run from tests/ directory. All paths relative to CWD.

Usage:
    ./mm3-vae-ref.py <checkpoint_dir> [t_latent]
    Nignore)categoryz../../diffusers/src)MiniMaxMusic3Vocoder)loggingc                  D   [         R                  S   n [        [         R                  5      S:  a  [        [         R                  S   5      OSn[        R
                  " U [        R                  S9nUR                  5         [        R                  " S5        [        R                  " SSU5      n[        R                  " 5          U" U5      nS S S 5        UR                  5       R                  S5      R                  S5        WR                  S	5      R                   R#                  5       R                  5       R                  S5      R                  S
5        [%        S['        UR(                  5      S['        UR(                  5      5        [%        SUR+                  5       R-                  5       UR/                  5       R-                  5       UR1                  S5      R3                  5       R5                  5       R-                  5       4-  5        g ! , (       d  f       GNI= f)N      @   )torch_dtype*      float32zparity/latent.binr   zparity/audio_ref.binlatentz-> audioz'audio stats: min %.6f max %.6f rms %.6f)sysargvlenintr   from_pretrainedtorchr   evalmanual_seedrandnno_gradnumpyastypetofilesqueezeT
contiguousprinttupleshapeminitemmaxpowmeansqrt)ckptt_latentmodelr   audios        mm3-vae-ref.pymainr.      sm   88A;D#&sxx=1#4s388A;"H 005==QE	JJL	b[[C*F	f 
 LLN)$++,?@	MM!!!#))+229=DDE[\	(E&,,'U5;;5GH	
3		EIIK,,.		!0A0A0C0H0H0J0O0O0Q7S S T 
s   	H
H__main__)__doc__r   warningsfilterwarningsFutureWarningpathinsertr   4diffusers.models.autoencoders.minimax_music3_vocoderr   diffusers.utilsr   diffusers_loggingdisable_progress_barr.   __name__     r-   <module>r=      sd        = 9 ( )  U 8  & & (T* zF r<   