o
    ְi                     @   s   d dl Z d dlZdddZdS )    Nc                 C   s@  | du rt  j}|j} g }i }t|  D ]E}t| | tjr[| | }t	|}|| v r9d
||| }d}n|||< |}d}dtt|j}	t|j}
|||	|
|jj|g qd}d}d}d}tt|D ]<}|| }|t|d k r~t|d }|t|d k rt|d }|t|d k rt|d }|d r|t|d 7 }qjt|dkrtd|}td|}td|}d	
|d
 |d
 |d
 }td
|dt|d   tt|D ]9}|| }td
|d d
|t|d  d  |d d
|t|d  d  |d d
|t|d  d  |d  qtd
| dS )a  Print the CuPy arrays in the given dictionary.

    Prints out the name, shape, bytes and type of all of the ndarrays
    present in `vardict`.

    If there is no dictionary passed in or `vardict` is None then returns
    CuPy arrays in the globals() dictionary (all CuPy arrays in the
    namespace).

    Args:
        vardict : (None or dict)  A dictionary possibly containing ndarrays.
                  Default is globals() if `None` specified


    .. admonition:: Example

        >>> a = cupy.arange(10)
        >>> b = cupy.ones(20)
        >>> cupy.who()
        Name            Shape            Bytes            Type
        ===========================================================
        <BLANKLINE>
        a               10               80               int64
        b               20               160              float64
        <BLANKLINE>
        Upper bound on total bytes  =       240
        >>> d = {'x': cupy.arange(2.0),
        ... 'y': cupy.arange(3.0), 'txt': 'Some str',
        ... 'idx':5}
        >>> cupy.who(d)
        Name            Shape            Bytes            Type
        ===========================================================
        <BLANKLINE>
        x               2                16               float64
        y               3                24               float64
        <BLANKLINE>
        Upper bound on total bytes  =       40

    Nz{} ({})r      z x       
   zName {} Shape {} Bytes {} Type z{}
{}
=   z{} {} {} {} {} {} {}   z'
Upper bound on total bytes  =       {})sys	_getframef_back	f_globalssortedkeys
isinstancecupyndarrayidformatjoinmapstrshapenbytesappenddtypenamerangelenintmaxprint)vardictframestacacher   varidvnamestroriginalshapestrbytestrmaxnamemaxshapemaxbyte
totalbyteskvalsp1sp2sp3prval r6   B/home/ubuntu/.local/lib/python3.10/site-packages/cupy/_misc/who.pywho   st   *




r8   )N)r
   r   r8   r6   r6   r6   r7   <module>   s    