
    sg                         d dl mZ d Zd Zy)    )ceilc                 B   t        t        d|            }t        | j                               D cg c]  }|D ]  }|  }}}g }|D ]-  }|j                  |      dkD  s||vs|j	                  |       / |D cg c]	  }||vs| }}|D cg c]	  }||vs| }	}t        |      dk7  rt        dt        |      z         t        |      dk7  rt        dt        |      z         t        |	      dk7  rt        dt        |	      z         y c c}}w c c}w c c}w )Nr      zDuplicate attention blocks specified in device_map. Attention blocks must be specified to one device. These attention blocks were specified more than once: zThere are attention blocks for this model that are not specified in the device_map. Add these attention blocks to a device on the device_map: zdThe device_map contains more attention blocks than this model has. Remove these from the device_map:)listrangevaluescountappendlen
ValueErrorstr)

device_map
num_blocksblockssublistitemdevice_map_blocksduplicate_blocksimissing_blocksextra_blockss
             Z/var/www/html/venv/lib/python3.12/site-packages/transformers/utils/model_parallel_utils.pyassert_device_mapr      sW   %:&'F-1*2C2C2E-F['SZ[4[[[  '""1%)a7G.G##A&' "(FA14E+EaFNF0D!AVOADLD
!FHKL\H]^
 	
 >a57:>7JK
 	
 <Ar, 
 	
 + \ GDs   D=	DD	DDc                     t        t        |             }t        t        | t	        |      z              }t        d| |      D cg c]
  }||||z     }}t        t        ||            S c c}w )zEReturns a dictionary of layers distributed evenly across all devices.r   )r   r   intr   r   dictzip)n_layersdeviceslayersn_blocksr   layers_lists         r   get_device_mapr#   2   sg    %/"F43w</01H5:1h5QR6!a(l+RKRG[)** Ss   A*N)mathr   r   r#        r   <module>r'      s     
>+r&   