
    ϑi                     D    S SK r S SKJrJr  S SKrS SKrSSKJr  S r	S r
g)    N)MappingSequence   )corec                 D  ^ U S   n[        U[        R                  5      (       a  [        R                  " U SS9n U $ [        U[        R
                  5      (       a  [        R                  " U SS9$ [        U[        R                  5      (       a  [        R                  " U 5      n U $ [        U[        [        45      (       a  U $ [        U[        5      (       a1  U VVs0 s H!  o"[        U  Vs/ s H  o3U   PM	     sn5      _M#     snn$ [        U[        5      (       a[  [        U5      m[        U4S j[!        U 5       5       5      (       d  [#        S5      e[%        U 6  Vs/ s H  n[        U5      PM     sn$ ['        S[)        U5       35      es  snf s  snnf s  snf )a  
Default batch collating function for :code:`paddle.io.DataLoader`,
get input data as a list of sample datas, each element in list
if the data of a sample, and sample data should composed of list,
dictionary, string, number, numpy array and paddle.Tensor, this
function will parse input data recursively and stack number,
numpy array and paddle.Tensor datas as batch datas. e.g. for
following input data:

[{'image': np.array(shape=[3, 224, 224]), 'label': 1},
 {'image': np.array(shape=[3, 224, 224]), 'label': 3},
 {'image': np.array(shape=[3, 224, 224]), 'label': 4},
 {'image': np.array(shape=[3, 224, 224]), 'label': 5},]


This default collate function zipped each number and numpy array
field together and stack each field as the batch field as follows:

{'image': np.array(shape=[4, 3, 224, 224]), 'label': np.array([1, 3, 4, 5])}


Args:
    batch(list of sample data): batch should be a list of sample data.

Returns:
    Batched data: batched each number, numpy array and paddle.Tensor
                  in input data.
r   )axisc              3   @   >#    U  H  n[        U5      T:H  v   M     g 7f)N)len).0samplesample_fields_nums     \/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/io/dataloader/collate.py	<genexpr>%default_collate_fn.<locals>.<genexpr>G   s     N+3v;"33+s   z/fields number not same among samples in a batchzQbatch data con only contains: tensor, numpy.ndarray, dict, list, number, but got )
isinstancenpndarraystackpaddleTensornumbersNumberarraystrbytesr   default_collate_fnr   r
   alliterRuntimeErrorzip	TypeErrortype)batchr   keydfieldsr   s        @r   r   r      sa   : 1XF&"**%%Q'	FFMM	*	*||E**	FGNN	+	+	FS%L	)	)	FG	$	$HN
HN#U$;UsVU$;<<
 	
 
FH	%	%KN$u+NNNA  :=eEv"6*EE
	''+F|n	6  %<
 Fs   F.F<F#FFc                    [        U [        R                  [        R                  [
        R                  R                  45      (       a  U $ [        U [        [        45      (       a  U $ [        U [        5      (       a  U  Vs0 s H  o[        X   5      _M     sn$ [        U [        5      (       a  U  Vs/ s H  n[        U5      PM     sn$ U $ s  snf s  snf )a{  
Default batch converting function for :code:`paddle.io.DataLoader`.
get input data as a list of sample datas, each element in list
if the data of a sample, and sample data should composed of list,
dictionary, string, number, numpy array and paddle.Tensor.

.. note::
    This function is default :attr:`collate_fn` in **Disable
    automatic batching** mode, for **Disable automatic batching**
    mode, please ses :attr:`paddle.io.DataLoader`

Args:
    batch(list of sample data): batch should be a list of sample data.

Returns:
    Batched data: batched each number, numpy array and paddle.Tensor
                  in input data.
)r   r   r   r   r   r   eagerr   r   r   default_convert_fnr   )r#   r$   r%   s      r   r)   r)   S   s    & %&--TZZ5F5FGHH	EC<	(	(	E7	#	#?DEu'
33uEE	E8	$	$/45u!"1%u55	 F5s   C4C)r   collections.abcr   r   numpyr   r   	frameworkr   r   r)        r   <module>r/      s!     -   7tr.   