o
    Èhr  ã                   @   s*   d dl mZ ddlmZ defdd„ZdS )é    )Ú
DataLoaderé   )Úis_torch_xla_availableÚ
dataloaderc                 C   s`   t ƒ r.dd lm  m} t| |jƒsJ dƒ‚dd lm  m} | | 	¡ d¡}|| j
d< | S | S )Nr   zPThe dataloader must be a `torch_xla.distributed.parallel_loader.MpDeviceLoader`.)ÚfsdpNÚinput_sharding)r   Ú%torch_xla.distributed.parallel_loaderÚdistributedÚparallel_loaderÚ
isinstanceÚMpDeviceLoaderÚtorch_xla.distributed.spmdÚspmdÚShardingSpecÚget_global_meshÚ_parallel_loader_kwargs)r   ÚplÚxsÚsharding_spec© r   úq/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/transformers/integrations/tpu.pyÚtpu_spmd_dataloader   s   ÿ
r   N)Útorch.utils.datar   Úutilsr   r   r   r   r   r   Ú<module>   s   