Ë
    ÿÍ:j³  ã                   ó„  — d dl mZ d dlmZmZ d dlZd dlmZ d dlm	Z	 de
e	   dee	   fd„Z	 	 ddeeeee
e   f      d	ed
edee
e      fd„Zdeeee
e   f   deee
e   f   fd„Zdde
e   d	ed
ede
e   fd„Zdeee
e   eedf   f   d	ed
edee
e      fd„Zdd	ed
ede
e   fd„Zde
e   ddfd„Zdeddfd„Zdefd„Zy)é    )ÚMutableSequence)ÚOptionalÚUnionN)ÚMisconfigurationException)Ú_DEVICEÚgpusÚreturnc                 ór   — | €yt        | t        «      st        d«      ‚t        | «      dkD  sJ d«       ‚| d   S )a  
    Args:
        gpus: Non-empty list of ints representing which GPUs to use

    Returns:
        Designated root GPU device id

    Raises:
        TypeError:
            If ``gpus`` is not a list
        AssertionError:
            If GPU list is empty
    NzGPUs should be a listr   zGPUs should be a non-empty list)Ú
isinstanceÚlistÚ	TypeErrorÚlen)r   s    ú}/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/lightning_fabric/utilities/device_parser.pyÚ_determine_root_gpu_devicer      sC   € ð €|Øä�dœDÔ!ÜÐ/Ó0Ð0äˆt‹9�qŠ=Ð;Ð;Ó;ˆ=ð �‰7€Nó    Úinclude_cudaÚinclude_mpsc                 óÆ  — t        | «       | �0t        | t        «      r| dk(  st        | «      j	                  «       dv ryt        | «      } t        | ||¬«      } | st        d«      ‚t        j                  j                  «       rGt        j                  j                  «       r)t        | «      dk7  rt        t        ||¬«      «      dk(  r| S t        | «       t        | ||¬«      S )aH  Parses the GPU IDs given in the format as accepted by the :class:`~pytorch_lightning.trainer.trainer.Trainer`.

    Args:
        gpus: An int -1 or string '-1' indicate that all available GPUs should be used.
            A list of unique ints or a string containing a list of comma separated unique integers
            indicates specific GPUs to use.
            An int of 0 means that no GPUs should be used.
            Any int N > 0 indicates that GPUs [0..N) should be used.
        include_cuda: A boolean value indicating whether to include CUDA devices for GPU parsing.
        include_mps: A boolean value indicating whether to include MPS devices for GPU parsing.

    Returns:
        A list of GPUs to be used or ``None`` if no GPUs were requested

    Raises:
        MisconfigurationException:
            If no GPUs are available but the value of gpus variable indicates request for GPUs

    .. note::
        ``include_cuda`` and ``include_mps`` default to ``False`` so that you only
        have to specify which device type to use and all other devices are not disabled.

    Nr   )Ú0z[]©r   r   z&GPUs requested but none are available.é   )Ú_check_data_typer   ÚintÚstrÚstripÚ!_normalize_parse_gpu_string_inputÚ"_normalize_parse_gpu_input_to_listr   ÚtorchÚdistributedÚis_availableÚis_torchelastic_launchedr   Ú_get_all_available_gpusÚ_check_uniqueÚ_sanitize_gpu_ids©r   r   r   s      r   Ú_parse_gpu_idsr&   1   sÉ   € ô: �TÔð €|œ
 4¬Ô-°$¸!²)ÄÀDÃ	ÇÁÓ@QÐU`Ñ@`Øô -¨TÓ2€DÜ-¨dÀÐ[fÔg€DÙÜ'Ð(PÓQÐQô 	×Ñ×&Ñ&Ô(Ü×Ñ×6Ñ6Ô8Ü�‹I˜ŠNÜÔ'°\È{Ô[Ó\Ð`aÒað ˆô �$Ôä˜T°È+ÔVÐVr   Úsc                 ó   — t        | t        «      s| S | dk(  ryd| v rE| j                  d«      D �cg c]*  }t        |«      dkD  sŒt	        |j                  «       «      ‘Œ, c}S t	        | j                  «       «      S c c}w )Nz-1éÿÿÿÿú,r   )r   r   Úsplitr   r   r   )r'   Úxs     r   r   r   j   se   € Ü�aœÔØˆØˆD‚yØØ
ˆa�xØ()¯©°«ÖC 1¼¸A»À»
”�A—G‘G“I•ÒCÐCÜˆq�w‰w‹y‹>Ðùò Ds   °A;ÁA;c                 óŽ   — t        ||f«      dk(  rt        d«      ‚t        ||¬«      }| D ]  }||vsŒt        d| › d|› �«      ‚ | S )as  Checks that each of the GPUs in the list is actually available. Raises a MisconfigurationException if any of the
    GPUs is not available.

    Args:
        gpus: List of ints corresponding to GPU indices

    Returns:
        Unmodified gpus variable

    Raises:
        MisconfigurationException:
            If machine has fewer available GPUs than requested.

    r   z*At least one gpu type should be specified!r   zYou requested gpu: z
 But your machine only has: )ÚsumÚ
ValueErrorr"   r   )r   r   r   Úall_available_gpusÚgpus        r   r$   r$   t   so   € ô ˆL˜+Ð&Ó'¨1Ò,ÜÐEÓFÐFÜ0¸lÐXcÔdÐØò ˆØÐ(Ò(Ü+Ø% d VÐ+IÐJ\ÐI]Ð^óð ðð
 €Kr   .c                 óž   — | €J ‚t        | t        t        f«      rt        | «      S | sy | dk(  rt	        ||¬«      S t        t        | «      «      S )Nr)   r   )r   r   Útupler   r"   Úranger%   s      r   r   r   Ž   sT   € ð ÐÐÐÜ�$œ¬%Ð0Ô1Ü�D‹zÐñ ØØˆr‚zÜ&°LÈkÔZÐZä”�d“ÓÐr   c                 óP   — ddl m} ddlm} | r |«       ng }|r |«       ng }||z   S )z7
    Returns:
        A list of all available GPUs
    r   )Ú_get_all_visible_cuda_devices)Ú_get_all_available_mps_gpus)Ú"lightning_fabric.accelerators.cudar6   Ú!lightning_fabric.accelerators.mpsr7   )r   r   r6   r7   Ú	cuda_gpusÚmps_gpuss         r   r"   r"   ž   s0   € õ
 QÝMá3?Ñ-Ô/ÀR€IÙ0;Ñ*Ô,À€HØ�xÑÐr   Ú
device_idsc                 óZ   — t        | «      t        t        | «      «      k7  rt        d«      ‚y)zÚChecks that the device_ids are unique.

    Args:
        device_ids: List of ints corresponding to GPUs indices

    Raises:
        MisconfigurationException:
            If ``device_ids`` of GPUs aren't unique

    z!Device ID's (GPU) must be unique.N)r   Úsetr   )r<   s    r   r#   r#   «   s*   € ô ˆ:ƒœ#œc *›oÓ.Ò.Ü'Ð(KÓLÐLð /r   c                 ó"  — d}| €t        |› d�«      ‚t        | t        t        f«      r?| D ]9  }t	        |«      }|t
        usŒt        |› dt	        |«      j                  › d�«      ‚ yt	        | «      t
        t        fvrt        |› d| ›d�«      ‚y)a3  Checks that the device_ids argument is one of the following: int, string, or sequence of integers.

    Args:
        device_ids: gpus/tpu_cores parameter as passed to the Trainer

    Raises:
        TypeError:
            If ``device_ids`` of GPU/TPUs aren't ``int``, ``str`` or sequence of ``int```

    zQDevice IDs (GPU/TPU) must be an int, a string, a sequence of ints, but you passedNz Nonez a sequence of ú.ú )r   r   r   r3   Útyper   Ú__name__r   )r<   ÚmsgÚid_Úid_types       r   r   r   º   s¥   € ð ^€CØÐÜ˜3˜%˜u˜Ó&Ð&Ü�*œ´Ð6Ô7Øò 	NˆCÜ˜3“iˆGØœcÒ!Ü 3 % ´t¸C³y×7IÑ7IÐ6JÈ!Ð LÓMÐMñ	Nô 
ˆjÓ	¤#¤s Ñ	+Ü˜3˜%˜q  ¨aÐ0Ó1Ð1ð 
,r   c                  óŽ   — ddl m}  ddlm} ddlm} |j                  «       ry|j                  «       ry| j                  «       ryy)	z8Choose the accelerator type (str) based on availability.r   )ÚCUDAAccelerator)ÚMPSAccelerator)ÚXLAAcceleratorÚtpuÚmpsÚcudaÚcpu)r8   rH   r9   rI   Ú!lightning_fabric.accelerators.xlarJ   r    )rH   rI   rJ   s      r   Ú_select_auto_acceleratorrP   Ñ   s;   € åBÝ@Ý@à×"Ñ"Ô$ØØ×"Ñ"Ô$ØØ×#Ñ#Ô%ØØr   )FF)Úcollections.abcr   Útypingr   r   r   Ú%lightning_fabric.utilities.exceptionsr   Ú lightning_fabric.utilities.typesr   r   r   r   r   Úboolr&   r   r$   r3   r   r"   r#   Úobjectr   rP   © r   r   ú<module>rX      s‡  ðõ ,ß "ã å KÝ 4ð T¨'¡]ð °xÀÑ7Hó ð8 Øñ6WØ
�5˜˜c 4¨¡9Ð,Ñ-Ñ
.ð6Wàð6Wð ð6Wð ˆd�3‰iÑó	6Wðr¨¨s°C¸¸c¹Ð/BÑ)Cð ÈÈcÐSWÐX[ÑS\ÈnÑH]ó ñ˜D ™Ið °Tð ÐPTð ÐaeÐfiÑajó ð4Ø
��T˜#‘Y  c¨3 h¡Ð/Ñ
0ðØ@DðØSWðàˆd�3‰iÑóñ 
 ¨$ð 
 ÀTð 
 ÐVZÐ[^ÑV_ó 
 ðM˜d 3™ið M¨Dó Mð2 ð 2¨Dó 2ð. #ô r   