
    miM                         d Z ddlZddlZddlZddlZdi fdej                  ej                  e      de	fdZ
 G d d      Z G d d	      Zy)
z*
Non signal processing related utilities.
    Nattrs	overridesc                    t        j                  | j                        j                  }g }|t	        |j                               }|D ]z  }d}||v r||   }nt        | |      rt        | |      }n)||v r3||   }|j                  t         j                  u s||j                  k7  rd}nd}|se|j                  | d|        | | j                  j                   ddj                  |       dS )z
    Return a simple representation string for `obj`.
    If `attrs` is not None, it should be a list of attributes to include.
    FT=(,))inspect	signature	__class__
parameterslistkeyshasattrgetattrdefault_emptyappend__name__join)	objr   r   params
attrs_reprattrdisplayvalueparams	            F/var/www/stems/demucs_env/lib/python3.12/site-packages/julius/utils.pysimple_reprr      s     s}}-88FJ}V[[]# 19dOES$C&E6>4LE}}.%5==2HGaw/0!1" mm$$%Qsxx
';&<A>>    c                   @    e Zd ZdZej
                  fdZd Zd Zd Z	y)MarkdownTablea9  
    Simple MarkdownTable generator. The column titles should be large enough
    for the lines content. This will right align everything.

    >>> import io  # we use io purely for test purposes, default is sys.stdout.
    >>> file = io.StringIO()
    >>> table = MarkdownTable(["Item Name", "Price"], file=file)
    >>> table.header(); table.line(["Honey", "5"]); table.line(["Car", "5,000"])
    >>> print(file.getvalue().strip())  # Strip for test purposes
    | Item Name | Price |
    |-----------|-------|
    |     Honey |     5 |
    |       Car | 5,000 |
    c                      || _         || _        y N)columnsfile)selfr%   r&   s      r   __init__zMarkdownTable.__init__:   s    	r    c                 d    | j                   j                  ddj                  |      z   dz          y )N|z|
)r&   writer   )r'   lines     r   _writelnzMarkdownTable._writeln>   s$    		chhtn,u45r    c                     | j                  d | j                  D               | j                  d | j                  D               y )Nc              3   (   K   | ]
  }d | d   yw) N .0cols     r   	<genexpr>z'MarkdownTable.header.<locals>.<genexpr>B   s     9S#aj9s   c              3   >   K   | ]  }d t        |      dz   z    yw)-   N)lenr2   s     r   r5   z'MarkdownTable.header.<locals>.<genexpr>C   s     CscSX\*Cs   )r-   r%   r'   s    r   headerzMarkdownTable.headerA   s.    9DLL99CdllCCr    c           
          g }t        || j                        D ]=  \  }}t        |dt        t	        |            z         }|j                  d|z   dz          ? | j                  |       y )N>r0   )zipr%   formatstrr9   r   r-   )r'   r,   outvalr4   s        r   r,   zMarkdownTable.lineE   s`    D$,,/ 	(HCcCCM12CJJsSy3'	( 	cr    N)
r   
__module____qualname____doc__sysstdoutr(   r-   r;   r,   r1   r    r   r"   r"   +   s%     &)ZZ 6Dr    r"   c                   "    e Zd ZdZd Zd Zd Zy)Chronoa  
    Measures ellapsed time, calling `torch.cuda.synchronize` if necessary.
    `Chrono` instances can be used as context managers (e.g. with `with`).
    Upon exit of the block, you can access the duration of the block in seconds
    with the `duration` attribute.

    >>> with Chrono() as chrono:
    ...     _ = sum(range(10_000))
    ...
    >>> print(chrono.duration < 10)  # Should be true unless on a really slow computer.
    True
    c                     d | _         y r$   )durationr:   s    r   r(   zChrono.__init__Z   s	    r    c                 8    t        j                          | _        | S r$   )time_beginr:   s    r   	__enter__zChrono.__enter__]   s    iikr    c                     dd l }|j                  j                         r|j                  j                          t	        j                         | j
                  z
  | _        y )Nr   )torchcudais_availablesynchronizerM   rN   rK   )r'   exc_type	exc_valueexc_tracebckrQ   s        r   __exit__zChrono.__exit__a   s;    ::""$JJ""$		dkk1r    N)r   rC   rD   rE   r(   rO   rX   r1   r    r   rI   rI   M   s    2r    rI   )rE   r
   typingtprF   rM   OptionalSequencer@   dictr   r"   rI   r1   r    r   <module>r^      s\      
  =A"$?BKKC(89 ??< D2 2r    