+
    &j1                     @   ^ RI t ^ RIHtHtHtHt ^ RIHtHt ^ RI	t	. ROt
]! R
RR7      t ! R R]],          4      t ! R R]],          4      t ! R R]],          4      t ! R R]],          4      t ! R R	]],          4      t ! R R]]],          ,          4      tR# )    N)IterableIteratorSequenceSized)GenericTypeVarBatchSamplerRandomSamplerSamplerSequentialSamplerSubsetRandomSamplerWeightedRandomSampler_T_coT)	covariantc                   6   a  ] tR t^t o RtV 3R lR ltRtV tR# )r   a  Base class for all Samplers.

Every Sampler subclass has to provide an :meth:`__iter__` method, providing a
way to iterate over indices or lists of indices (batches) of dataset elements,
and may provide a :meth:`__len__` method that returns the length of the returned iterators.

Example:
    >>> # xdoctest: +SKIP
    >>> class AccedingSequenceLengthSampler(Sampler[int]):
    >>>     def __init__(self, data: List[str]) -> None:
    >>>         self.data = data
    >>>
    >>>     def __len__(self) -> int:
    >>>         return len(self.data)
    >>>
    >>>     def __iter__(self) -> Iterator[int]:
    >>>         sizes = torch.tensor([len(x) for x in self.data])
    >>>         yield from torch.argsort(sizes).tolist()
    >>>
    >>> class AccedingSequenceLengthBatchSampler(Sampler[List[int]]):
    >>>     def __init__(self, data: List[str], batch_size: int) -> None:
    >>>         self.data = data
    >>>         self.batch_size = batch_size
    >>>
    >>>     def __len__(self) -> int:
    >>>         return (len(self.data) + self.batch_size - 1) // self.batch_size
    >>>
    >>>     def __iter__(self) -> Iterator[List[int]]:
    >>>         sizes = torch.tensor([len(x) for x in self.data])
    >>>         for batch in torch.chunk(torch.argsort(sizes), len(self)):
    >>>             yield batch.tolist()

.. note:: The :meth:`__len__` method isn't strictly required by
          :class:`~torch.utils.data.DataLoader`, but is expected in any
          calculation involving the length of a :class:`~torch.utils.data.DataLoader`.
c                0   < V ^8  d   QhRS[ S[,          /#    return)r   r   )format__classdict__s   "p/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/torch/utils/data/sampler.py__annotate__Sampler.__annotate__B   s     " "(5/ "    c                    \         hN)NotImplementedErrorselfs   &r   __iter__Sampler.__iter__B   s    !!r    N)__name__
__module____qualname____firstlineno____doc__r!   __static_attributes____classdictcell__r   s   @r   r   r      s     #J" "r   c                   f   a  ] tR t^at o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R ltR	t	V t
R
# )r   zSamples elements sequentially, always in the same order.

Args:
    data_source (Sized): data source to sample from. Must implement __len__.
c                $   < V ^8  d   QhRS[ RR/# )r   data_sourcer   Nr   )r   r   s   "r   r   SequentialSampler.__annotate__j   s     ' 'E 'd 'r   c                    Wn         R # r   r.   )r    r.   s   &&r   __init__SequentialSampler.__init__j   s    &r   c                0   < V ^8  d   QhRS[ S[,          /# r   r   int)r   r   s   "r   r   r0   m   s     2 2(3- 2r   c                P    \        \        \        V P                  4      4      4      # r   )iterrangelenr.   r   s   &r   r!   SequentialSampler.__iter__m   s    E#d../011r   c                    < V ^8  d   QhRS[ /# r   r7   )r   r   s   "r   r   r0   p   s     % % %r   c                ,    \        V P                  4      # r   )r;   r.   r   s   &r   __len__SequentialSampler.__len__p   s    4##$$r   c                &   < V ^8  d   Qh/ S[ ;R&   # )r   r.   r/   )r   r   s   "r   r   r0   a   s       r   r2   Nr$   r%   r&   r'   r(   r3   r!   r@   __annotate_func__r)   r*   r+   s   @r   r   r   a   s/     ' '2 2% %  r   c                      a  ] tR t^tt o RtRV 3R lR llt]V 3R lR l4       tV 3R lR ltV 3R	 lR
 lt	V 3R lt
RtV tR# )r
   a  Samples elements randomly. If without replacement, then sample from a shuffled dataset.

If with replacement, then user can specify :attr:`num_samples` to draw.

Args:
    data_source (Sized): data source to sample from. Must implement __len__.
    replacement (bool): samples are drawn on-demand with replacement if ``True``, default=``False``
    num_samples (int): number of samples to draw, default=`len(dataset)`.
    generator (Generator): Generator used in sampling.
Nc                >   < V ^8  d   QhRS[ RS[RS[R,          RR/# )r   r.   replacementnum_samplesNr   )r   boolr7   )r   r   s   "r   r   RandomSampler.__annotate__   s7        4Z	 
r   c                8   Wn         W n        W0n        W@n        \	        V P                  \
        4      '       g   \        R V P                   24      h\	        V P                  \        4      '       d   V P                  ^ 8:  d   \        RV P                   24      hR# );replacement should be a boolean value, but got replacement=Dnum_samples should be a positive integer value, but got num_samples=N)
r.   rG   _num_samples	generator
isinstancerI   	TypeErrorrH   r7   
ValueError)r    r.   rG   rH   rO   s   &&&&&r   r3   RandomSampler.__init__   s     '&'"$**D11MdN^N^M_`  $**C00D4D4D4IVW[WgWgVhi  5Jr   c                    < V ^8  d   QhRS[ /# r   r>   )r   r   s   "r   r   rJ      s     ! !S !r   c                `    V P                   f   \        V P                  4      # V P                   # r   )rN   r;   r.   r   s   &r   rH   RandomSampler.num_samples   s-     $t''((   r   c                0   < V ^8  d   QhRS[ S[,          /# r   r6   )r   r   s   "r   r   rJ      s      (3- r   c              #    "   \        V P                  4      pV P                  fs   \        \        P
                  ! R\        P                  R7      P                  4       P                  4       4      p\        P                  ! 4       pVP                  V4       MV P                  pV P                  '       d   \        V P                  ^ ,          4       FA  p\        P                  ! VR\        P                  VR7      P                  4        R j  xL
  KC  	  \        P                  ! VV P                  ^ ,          3\        P                  VR7      P                  4        R j  xL
  R # \        V P                  V,          4       F0  p\        P                   ! WR7      P                  4        R j  xL
  K2  	  \        P                   ! WR7      P                  4       R V P                  V,            R j  xL
  R #  L L LO L5i)Ndtype)highsizerZ   rO   rO   r#   )    )r;   r.   rO   r7   torchemptyint64random_item	Generatormanual_seedrG   r:   rH   randinttolistrandperm)r    nseedrO   _s   &    r   r!   RandomSampler.__iter__   s|      !>>!u{{2U[[9AACHHJKD)I!!$'I4++r12 ==ekkY&(  3 }}&&+-kk#	
 fh  4++q01 >>!AHHJJJ 2~~a=DDF&$""Q&   KsR   B3H6AHG<AH"G>#AH0H 1AH5H6H>H HHc                    < V ^8  d   QhRS[ /# r   r>   )r   r   s   "r   r   rJ                r   c                    V P                   # r   rH   r   s   &r   r@   RandomSampler.__len__       r   c                2   < V ^8  d   Qh/ S[ ;R&   S[;R&   # )r   r.   rG   )r   rI   )r   r   s   "r   r   rJ   t   s         r   )rN   r.   rO   rG   )FNN)r$   r%   r&   r'   r(   r3   propertyrH   r!   r@   rD   r)   r*   r+   s   @r   r
   r
   t   sD     	 , ! ! 6   O  r   c                   j   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tR
t	V t
R# )r   zSamples elements randomly from a given list of indices, without replacement.

Args:
    indices (sequence): a sequence of indices
    generator (Generator): Generator used in sampling.
Nc                4   < V ^8  d   QhRS[ S[,          RR/# )r   indicesr   Nr   r7   )r   r   s   "r   r    SubsetRandomSampler.__annotate__   s     # # #$ #r   c                    Wn         W n        R # r   )rw   rO   )r    rw   rO   s   &&&r   r3   SubsetRandomSampler.__init__   s    "r   c                0   < V ^8  d   QhRS[ S[,          /# r   r6   )r   r   s   "r   r   ry      s     " "(3- "r   c              #     "   \         P                  ! \        V P                  4      V P                  R 7      P                  4        F  pV P                  V,          x  K  	  R# 5ir]   N)r_   rh   r;   rw   rO   rg   )r    is   & r   r!   SubsetRandomSampler.__iter__   s?     DLL 1T^^LSSUA,,q/! Vs   A"A$c                    < V ^8  d   QhRS[ /# r   r>   )r   r   s   "r   r   ry      s     ! ! !r   c                ,    \        V P                  4      # r   )r;   rw   r   s   &r   r@   SubsetRandomSampler.__len__   s    4<<  r   c                6   < V ^8  d   Qh/ S[ S[,          ;R&   # )r   rw   rx   )r   r   s   "r   r   ry      s      c] r   )rO   rw   r   rC   r+   s   @r   r   r      s/     # #" "! !%  r   c                   j   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tR
t	V t
R# )r   a~  Samples elements from ``[0,..,len(weights)-1]`` with given probabilities (weights).

Args:
    weights (sequence)   : a sequence of weights, not necessary summing up to one
    num_samples (int): number of samples to draw
    replacement (bool): if ``True``, samples are drawn with replacement.
        If not, they are drawn without replacement, which means that when a
        sample index is drawn for a row, it cannot be drawn again for that row.
    generator (Generator): Generator used in sampling.

Example:
    >>> # xdoctest: +IGNORE_WANT("non-deterministic")
    >>> list(
    ...     WeightedRandomSampler(
    ...         [0.1, 0.9, 0.4, 0.7, 3.0, 0.6], 5, replacement=True
    ...     )
    ... )
    [4, 4, 1, 4, 5]
    >>> list(
    ...     WeightedRandomSampler(
    ...         [0.9, 0.4, 0.05, 0.2, 0.3, 0.1], 5, replacement=False
    ...     )
    ... )
    [0, 1, 4, 3, 2]
Nc                @   < V ^8  d   QhRS[ S[,          RS[RS[RR/# )r   weightsrH   rG   r   N)r   floatr7   rI   )r   r   s   "r   r   "WeightedRandomSampler.__annotate__   s7     # #%# # 	# 
#r   c                   \        V\        4      '       d   \        V\        4      '       g   V^ 8:  d   \        RV 24      h\        V\        4      '       g   \        RV 24      h\        P
                  ! V\        P                  R7      p\        VP                  4      ^8w  d"   \        R\        VP                  4       24      hWPn
        W n        W0n        W@n        R# )r   rM   rL   rY   z=weights should be a 1d sequence but given weights have shape N)rP   r7   rI   rR   r_   	as_tensordoubler;   shapetupler   rH   rG   rO   )r    r   rH   rG   rO   weights_tensors   &&&&& r   r3   WeightedRandomSampler.__init__   s     ;,,+t,,aVWbVcd  +t,,Mk][  E~##$)&&+N,@,@&A%BD 
 &&&"r   c                0   < V ^8  d   QhRS[ S[,          /# r   r6   )r   r   s   "r   r   r     s     . .(3- .r   c              #     "   \         P                  ! V P                  V P                  V P                  V P
                  R 7      p\        VP                  4       4       Rj  xL
  R#  L5ir~   )r_   multinomialr   rH   rG   rO   r9   rg   )r    rand_tensors   & r   r!   WeightedRandomSampler.__iter__  sK     ''LL$**D,<,<
 **,---s   AA*!A("A*c                    < V ^8  d   QhRS[ /# r   r>   )r   r   s   "r   r   r     rn   r   c                    V P                   # r   rp   r   s   &r   r@   WeightedRandomSampler.__len__  rr   r   c                R   < V ^8  d   Qh/ S[ P                  ;R&   S[;R&   S[;R&   # )r   r   rH   rG   )r_   Tensorr7   rI   )r   r   s   "r   r   r      s0     6 \\7 8 9 : ; r   )rO   rH   rG   r   )TNrC   r+   s   @r   r   r      s1     <# #@. .   K  r   c                   Z   a  ] tR tRt o R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	   i  a  Wraps another sampler to yield a mini-batch of indices.

Args:
    sampler (Sampler or Iterable): Base sampler. Can be any iterable object
    batch_size (int): Size of mini-batch.
    drop_last (bool): If ``True``, the sampler will drop the last batch if
        its size would be less than ``batch_size``

Example:
    >>> list(
    ...     BatchSampler(
    ...         SequentialSampler(range(10)), batch_size=3, drop_last=False
    ...     )
    ... )
    [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]
    >>> list(
    ...     BatchSampler(SequentialSampler(range(10)), batch_size=3, drop_last=True)
    ... )
    [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
c                `   < V ^8  d   QhRS[ S[,          S[S[,          ,          RS[RS[RR/# )r   sampler
batch_size	drop_lastr   N)r   r7   r   rI   )r   r   s   "r   r   BatchSampler.__annotate__4  s@     # #-# # 	#
 
#r   c                    \        V\        4      '       d   \        V\        4      '       g   V^ 8:  d   \        RV 24      h\        V\        4      '       g   \        RV 24      hWn        W n        W0n        R# )r   zBbatch_size should be a positive integer value, but got batch_size=z7drop_last should be a boolean value, but got drop_last=N)rP   r7   rI   rR   r   r   r   )r    r   r   r   s   &&&&r   r3   BatchSampler.__init__4  su     :s++*d++QTU_T`a  )T**I)U  $"r   c                @   < V ^8  d   QhRS[ S[S[,          ,          /# r   )r   listr7   )r   r   s   "r   r   r   M  s      K K(49- Kr   c              #  \  "   \        V P                  4      pV P                  '       d/   V.V P                  ,          p\	        VR R/  F	  p. VOx  K  	  R# . \
        P                  ! WP                  4      OpV'       d)   Vx  . \
        P                  ! WP                  4      OpK0  R# 5i)strictFN)r9   r   r   r   zip	itertoolsislice)r    sampler_iterargsbatch_droplastbatchs   &    r   r!   BatchSampler.__iter__M  s     DLL)>>> >DOO3D"%t":E":''' #; Gi&&|__EFEJ)**<IJ s   A?B,*B,c                    < V ^8  d   QhRS[ /# r   r>   )r   r   s   "r   r   r   Z  s     P P Pr   c                    V P                   '       d'   \        V P                  4      V P                  ,          # \        V P                  4      V P                  ,           ^,
          V P                  ,          # )   )r   r;   r   r   r   s   &r   r@   BatchSampler.__len__Z  sK    
 >>>t||$77%7!;OOr   )r   r   r   N)
r$   r%   r&   r'   r(   r3   r!   r@   r)   r*   r+   s   @r   r	   r	     s,     *# #2K KP Pr   )r	   r
   r   r   r   r   )r   collections.abcr   r   r   r   typingr   r   r_   __all__r   r   r7   r   r
   r   r   r   r	   r#   r   r   <module>r      s     ? ? #  	4('"gen '"J% %&H GCL H V!'#, !,F GCL F RDP749% DPr   