+
    &j3                         ^ RI t ^ RIHt ^ RIHt ^ RIt^ RIHt ^ RI	H
t
 ^ RIHt R.t]! RRR	7      t ! R
 R]],          4      tR# )    N)Iterator)TypeVar)Dataset)SamplerDistributedSampler_T_coT)	covariantc                   p   a  ] tR t^t o RtRV 3R lR lltV 3R lR ltV 3R lR ltV 3R	 lR
 ltRt	V t
R# )r   a  Sampler that restricts data loading to a subset of the dataset.

It is especially useful in conjunction with
:class:`torch.nn.parallel.DistributedDataParallel`. In such a case, each
process can pass a :class:`~torch.utils.data.DistributedSampler` instance as a
:class:`~torch.utils.data.DataLoader` sampler, and load a subset of the
original dataset that is exclusive to it.

.. note::
    Dataset is assumed to be of constant size and that any instance of it always
    returns the same elements in the same order.

Args:
    dataset: Dataset used for sampling.
    num_replicas (int, optional): Number of processes participating in
        distributed training. By default, :attr:`world_size` is retrieved from the
        current distributed group.
    rank (int, optional): Rank of the current process within :attr:`num_replicas`.
        By default, :attr:`rank` is retrieved from the current distributed
        group.
    shuffle (bool, optional): If ``True`` (default), sampler will shuffle the
        indices.
    seed (int, optional): random seed used to shuffle the sampler if
        :attr:`shuffle=True`. This number should be identical across all
        processes in the distributed group. Default: ``0``.
    drop_last (bool, optional): if ``True``, then the sampler will drop the
        tail of the data to make it evenly divisible across the number of
        replicas. If ``False``, the sampler will add extra indices to make
        the data evenly divisible across the replicas. Default: ``False``.

.. warning::
    In distributed mode, calling the :meth:`set_epoch` method at
    the beginning of each epoch **before** creating the :class:`DataLoader` iterator
    is necessary to make shuffling work properly across multiple epochs. Otherwise,
    the same ordering will be always used.

Example::

    >>> # xdoctest: +SKIP
    >>> sampler = DistributedSampler(dataset) if is_distributed else None
    >>> loader = DataLoader(dataset, shuffle=(sampler is None),
    ...                     sampler=sampler)
    >>> for epoch in range(start_epoch, n_epochs):
    ...     if is_distributed:
    ...         sampler.set_epoch(epoch)
    ...     train(loader)
Nc                ^   < V ^8  d   QhRS[ RS[R,          RS[R,          RS[RS[RS[RR/# )	   datasetnum_replicasNrankshuffleseed	drop_lastreturn)r   intbool)format__classdict__s   "t/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/torch/utils/data/distributed.py__annotate__DistributedSampler.__annotate__B   sY     ' '' Dj' Dj	'
 ' ' ' 
'    c                   Vf<   \         P                  ! 4       '       g   \        R4      h\         P                  ! 4       pVf<   \         P                  ! 4       '       g   \        R4      h\         P                  ! 4       pW28  g   V^ 8  d   \        RV RV^,
           R24      hWn        W n        W0n        ^ V n	        W`n
        V P                  '       d}   \        V P                  4      V P                  ,          ^ 8w  dR   \        P                  ! \        V P                  4      V P                  ,
          V P                  ,          4      V n        M?\        P                  ! \        V P                  4      V P                  ,          4      V n        V P                  V P                  ,          V n        W@n        WPn        R # )Nz,Requires distributed package to be availablezInvalid rank z%, rank should be in the interval [0, ])distis_availableRuntimeErrorget_world_sizeget_rank
ValueErrorr   r   r   epochr   lenmathceilnum_samples
total_sizer   r   )selfr   r   r   r   r   r   s   &&&&&&&r   __init__DistributedSampler.__init__B   sT    $$&&"#QRR..0L<$$&&"#QRR==?D4!8v%J<Z[K[J\\]^  (	
" >>>c$,,/$2C2CCqH  $yyT\\"T%6%66$:K:KK D  $yyT\\):T=N=N)NOD**T->->>	r   c                0   < V ^8  d   QhRS[ S[,          /# r   r   )r   r   )r   r   s   "r   r   r   k   s     " "(5/ "r   c                   V P                   '       d|   \        P                  ! 4       pVP                  V P                  V P
                  ,           4       \        P                  ! \        V P                  4      VR 7      P                  4       pM'\        \        \        V P                  4      4      4      pV P                  '       gp   V P                  \        V4      ,
          pV\        V4      8:  d   W"RV ,          pMFW"\        P                  ! V\        V4      ,          4      ,          RV ,          pMVRV P                   p\        V4      V P                  8w  d&   \!        R\        V4       RV P                   R24      hW P"                  V P                  V P$                  1,          p\        V4      V P&                  8w  d&   \!        R\        V4       RV P&                   R24      h\)        V4      # ))	generatorNzNumber of indices (z) does not match total_size ()zNumber of subsampled indices (z) does not match num_samples ()r   torch	Generatormanual_seedr   r$   randpermr%   r   tolistlistranger   r)   r&   r'   AssertionErrorr   r   r(   iter)r*   gindicespadding_sizes   &   r   __iter__DistributedSampler.__iter__k   s   <<<!AMM$))djj01nnS%6!DKKMG5T\\!234G~~~??S\9Ls7|+=L11diis7|0K&LL!\ 
 /0Gw<4??* %c'l^3PQUQ`Q`Paabc 
 ))doo8I8IIJw<4+++ 0W>\]a]m]m\nnop 
 G}r   c                    < V ^8  d   QhRS[ /# r.   r   )r   r   s   "r   r   r      s          r   c                    V P                   # )N)r(   )r*   s   &r   __len__DistributedSampler.__len__   s    r   c                $   < V ^8  d   QhRS[ RR/# )r   r$   r   NrA   )r   r   s   "r   r   r      s      s t r   c                    Wn         R# )z
Set the epoch for this sampler.

When :attr:`shuffle=True`, this ensures all replicas
use a different random ordering for each epoch. Otherwise, the next iteration of this
sampler will yield the same ordering.

Args:
    epoch (int): Epoch number.
N)r$   )r*   r$   s   &&r   	set_epochDistributedSampler.set_epoch   s	     
r   )	r   r   r$   r   r(   r   r   r   r)   )NNTr   F)__name__
__module____qualname____firstlineno____doc__r+   r>   rC   rG   __static_attributes____classdictcell__)r   s   @r   r   r      s5     .`' 'R" "H    r   )r&   collections.abcr   typingr   r2   torch.distributeddistributedr   torch.utils.data.datasetr   torch.utils.data.samplerr   __all__r   r    r   r   <module>rX      sD     $     , ,  
  	4(L Lr   