
    vj                     .    d dl mZ d dlZd dlmZ ddZdS )    )MappingN)ModelOutputBaseFc                    t          | t                    r:t          t          |                     D ]}t	          | |                   | |<   | S t          | t
                    st          | t                    rut          | d          r/|                                 D ]\  }}t	          |          | |<   | S  t          |           fd|                                 D                       S t          | t          t          f          r$ t          |           fd| D                       S t          | t          j                  r|                     |          S | S )a   Put the data to the target cuda device just before the forward function.
    Args:
        batch: The batch data out of the dataloader.
        device: (str | torch.device): The target device for the data.

    Returns: The data to the target device.

    __setitem__c                 8    i | ]\  }}|t          |          S  	to_device).0kvdevices      k/lsinfo/ai/hellotax_ai/data_center/backend/venv/lib/python3.11/site-packages/modelscope/utils/data_utils.py
<dictcomp>zto_device.<locals>.<dictcomp>   s9     , , ,Q Ia(( , , ,    c              3   8   K   | ]}t          |          V  d S )Nr	   )r   r   r   s     r   	<genexpr>zto_device.<locals>.<genexpr>!   s-      ??A9Q//??????r   )non_blocking)
isinstancer   rangelenr
   dictr   hasattritemstypetuplelisttorchTensorto)batchr   r   idxr   r   s    `    r   r
   r
   	   sv    %)) U$$ 	7 	7C"5:v66E#JJ	E4	 	  Jug$>$> 5-(( 	- 0 01$Q//aL4;;, , , ,"[[]], , ,- - - 
EE4=	)	) tE{{??????????	E5<	(	( xx\x:::r   )F)collections.abcr   r   modelscope.outputsr   r
   r   r   r   <module>r%      sP    # # # # # #  . . . . . .     r   