+
    QV-jñ-  ã                   óÖ   € ^ RI HtHt ^RIHtHtHt ^RIHtH	t	 ^RI
Ht ^RIHtHtHt ^RIHt ^RIHt ^RIHt ]P,                  ! ]4      t]! R	]]4      tRR R lltRR R lltR
# )é    )ÚOptionalÚTypeVar)ÚDatasetÚ_concatenate_map_style_datasetsÚ_interleave_map_style_datasets)ÚDatasetDictÚIterableDatasetDict)ÚDatasetInfo)ÚIterableDatasetÚ_concatenate_iterable_datasetsÚ_interleave_iterable_datasets)Ú
NamedSplit)Úlogging)ÚLiteralÚDatasetTypeNc                óþ   € V ^8„  d   QhR\         \        ,          R\        \         \        ,          ,          R\        \        ,          R\        \
        ,          R\        \        ,          R\        R,          R\        /# )	é   ÚdatasetsÚprobabilitiesÚseedÚinfoÚsplitÚstopping_strategyÚreturn©Úfirst_exhaustedÚall_exhaustedÚ!all_exhausted_without_replacement)Úlistr   r   ÚfloatÚintr
   r   r   )Úformats   "Úa/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/datasets/combine.pyÚ__annotate__r$      s{   € ÷ S
ñ S
Ü”;ÕðS
äœD¤�KÕ(ðS
ô ”3�-ðS
ô ”;Õ
ð	S
ô
 ”JÕðS
ô ØOõðS
ô ñS
ó    c                óÌ  € ^RI Hp ^RIHp V '       g   \	        R4      h\        V 4       Fý  w  r‰\        W–V34      '       g‰   \        V	\        \        34      '       dH   V	'       g   \	        RV R24      h\	        RV R\        V	4       R\        \        V	4      4       R	24      h\	        RV R
\        V	4      P                   R24      hV^ 8X  d   \        W–4      '       d   Wg3MWv3w  r«KÂ  \        V	X
4      '       d   KÖ  \	        RV
P                   RXP                   RV R24      h	  VR9  d   \	        V R24      hX
VJ d   \        WW#WER7      # \        V VVVVVR7      # )u  
Interleave several datasets (sources) into a single dataset.
The new dataset is constructed by alternating between the sources to get the examples.

You can use this function on a list of [`Dataset`] objects, or on a list of [`IterableDataset`] objects.

    - If `probabilities` is `None` (default) the new dataset is constructed by cycling between each source to get the examples.
    - If `probabilities` is not `None`, the new dataset is constructed by getting examples from a random source at a time according to the provided probabilities.

The resulting dataset ends when one of the source datasets runs out of examples except when `oversampling` is `True`,
in which case, the resulting dataset ends when all datasets have ran out of examples at least one time.

Note for iterable datasets:

* The resulting dataset's `num_shards` is the minimum of each dataset's `num_shards` to ensure good parallelism.
  If some of your datasets have a very low number of shards, you may use [`IterableDataset.reshard`].
* In a distributed setup or in PyTorch DataLoader workers, the stopping strategy is applied per process.
  Therefore the "first_exhausted" strategy on an sharded iterable dataset can generate less samples in total (up to 1 missing sample per subdataset per worker).

Args:
    datasets (`List[Dataset]` or `List[IterableDataset]`):
        List of datasets to interleave.
    probabilities (`List[float]`, *optional*, defaults to `None`):
        If specified, the new dataset is constructed by sampling
        examples from one source at a time according to these probabilities.
    seed (`int`, *optional*, defaults to `None`):
        The random seed used to choose a source for each example.
    info ([`DatasetInfo`], *optional*):
        Dataset information, like description, citation, etc.
        <Added version="2.4.0"/>
    split ([`NamedSplit`], *optional*):
        Name of the dataset split.
        <Added version="2.4.0"/>
    stopping_strategy (`str`, defaults to `first_exhausted`):
        Three strategies are proposed right now, `first_exhausted`, `all_exhausted` and `all_exhausted_without_replacement`.
        By default, `first_exhausted` is an undersampling strategy, i.e the dataset construction is stopped as soon as one dataset has ran out of samples.
        If the strategy is `all_exhausted`,  we use an oversampling strategy, i.e the dataset construction is stopped as soon as every samples of every dataset has been added at least once.
        When strategy is `all_exhausted_without_replacement` we make sure that each sample in each dataset is sampled only once.
        Note that if the strategy is `all_exhausted`, the interleaved dataset size can get enormous:
        - with no probabilities, the resulting dataset will have `max_length_datasets*nb_dataset` samples.
        - with given probabilities, the resulting dataset will have more samples if some datasets have really low probability of visiting.
Returns:
    [`Dataset`] or [`IterableDataset`]: Return type depends on the input `datasets`
    parameter. `Dataset` if the input is a list of `Dataset`, `IterableDataset` if the input is a list of
    `IterableDataset`.

Example:

    For regular datasets (map-style):

    ```python
    >>> from datasets import Dataset, interleave_datasets
    >>> d1 = Dataset.from_dict({"a": [0, 1, 2]})
    >>> d2 = Dataset.from_dict({"a": [10, 11, 12]})
    >>> d3 = Dataset.from_dict({"a": [20, 21, 22]})
    >>> dataset = interleave_datasets([d1, d2, d3], probabilities=[0.7, 0.2, 0.1], seed=42, stopping_strategy="all_exhausted")
    >>> dataset["a"]
    [10, 0, 11, 1, 2, 20, 12, 10, 0, 1, 2, 21, 0, 11, 1, 2, 0, 1, 12, 2, 10, 0, 22]
    >>> dataset = interleave_datasets([d1, d2, d3], probabilities=[0.7, 0.2, 0.1], seed=42)
    >>> dataset["a"]
    [10, 0, 11, 1, 2]
    >>> dataset = interleave_datasets([d1, d2, d3])
    >>> dataset["a"]
    [0, 10, 20, 1, 11, 21, 2, 12, 22]
    >>> dataset = interleave_datasets([d1, d2, d3], stopping_strategy="all_exhausted")
    >>> dataset["a"]
    [0, 10, 20, 1, 11, 21, 2, 12, 22]
    >>> d1 = Dataset.from_dict({"a": [0, 1, 2]})
    >>> d2 = Dataset.from_dict({"a": [10, 11, 12, 13]})
    >>> d3 = Dataset.from_dict({"a": [20, 21, 22, 23, 24]})
    >>> dataset = interleave_datasets([d1, d2, d3])
    >>> dataset["a"]
    [0, 10, 20, 1, 11, 21, 2, 12, 22]
    >>> dataset = interleave_datasets([d1, d2, d3], stopping_strategy="all_exhausted")
    >>> dataset["a"]
    [0, 10, 20, 1, 11, 21, 2, 12, 22, 0, 13, 23, 1, 10, 24]
    >>> dataset = interleave_datasets([d1, d2, d3], probabilities=[0.7, 0.2, 0.1], seed=42)
    >>> dataset["a"]
    [10, 0, 11, 1, 2]
    >>> dataset = interleave_datasets([d1, d2, d3], probabilities=[0.7, 0.2, 0.1], seed=42, stopping_strategy="all_exhausted")
    >>> dataset["a"]
    [10, 0, 11, 1, 2, 20, 12, 13, ..., 0, 1, 2, 0, 24]
    For datasets in streaming mode (iterable):

    >>> from datasets import interleave_datasets
    >>> d1 = load_dataset('allenai/c4', 'es', split='train', streaming=True)
    >>> d2 = load_dataset('allenai/c4', 'fr', split='train', streaming=True)
    >>> dataset = interleave_datasets([d1, d2])
    >>> iterator = iter(dataset)
    >>> next(iterator)
    {'text': 'Comprar Zapatillas para niÃ±a en chancla con goma por...'}
    >>> next(iterator)
    {'text': 'Le sacre de philippe ier, 23 mai 1059 - Compte Rendu...'
    ```
)r   )r   z/Unable to interleave an empty list of datasets.úaExpected a list of Dataset objects or a list of IterableDataset objects, but element at position ú  is an empty dataset dictionary.úDataset at position ú has at least one split: úN
Please pick one to interleave with the other datasets, for example: dataset['ú']ú is a Ú.úUnable to interleave a ú (at position 0) with a ú (at position úK). Expected a list of Dataset objects or a list of IterableDataset objects.z: is not supported. Please enter a valid stopping_strategy.)r   r   r   r   )Úarrow_datasetr   Úiterable_datasetr   Ú
ValueErrorÚ	enumerateÚ
isinstancer   r	   r   ÚnextÚiterÚtypeÚ__name__r   r   )r   r   r   r   r   r   r   r   ÚiÚdatasetÚdataset_typeÚ
other_types   &&&&&&      r#   Úinterleave_datasetsr@      sÛ  € õR 'Ý1çÜÐJÓKÐKÜ Ö)‰
ˆÜ˜'¨_Ð#=×>Ò>Ü˜'¤KÔ1DÐ#E×FÒFßÜ$Ø{Ð|}Ð{~ð :ð :óð ô !Ø*¨1¨#Ð-FÄtÈGÃ}Àoð VdÜdhÔimÐnuÓivÓdwÐcxÐxzð|óð ô ØsÐtuÐsvÐv|ô  ~Bð  CJó  ~K÷  ~Tñ  ~Tð  }Uð  UVð  Wóð ð �Œ6ä.8¸×.JÒ.J�Ñ*ÐQ`ÐPjñ %ˆL™*ô ˜G \×2Ô2ÜØ)¨,×*?Ñ*?Ð)@Ð@XÐYc×YlÑYlÐXmÐm{Ð|}Ð{~ð  Jð  Kóð ñ) *ð. Ð iÔiÜÐ-Ð.Ð.hÐiÓjÐjØ�wÓÜ-Ø T¸Eô
ð 	
ô -ØØØØØØ/ô
ð 	
r%   c          
      ó–   € V ^8„  d   QhR\         \        ,          R\        \        ,          R\        \        ,          R\
        R\        /# )r   Údsetsr   r   Úaxisr   )r   r   r   r
   r   r!   )r"   s   "r#   r$   r$   ¨   sW   € ÷ @Xñ @XÜ”Õð@Xä
”;Õ
ð@Xô ”JÕð@Xô ð	@Xô
 ñ@Xr%   c                óÊ  € V '       g   \        R4      h\        V 4       EF  w  rE\        V\        \        34      '       g‰   \        V\
        \        34      '       dH   V'       g   \        RV R24      h\        RV R\        V4       R\        \        V4      4       R24      h\        RV R\        V4      P                   R	24      hV^ 8X  d3   \        V\        4      '       d   \        \        3M\        \        3w  rgKã  \        VX4      '       d   K÷  \        R
VP                   RXP                   RV R24      h	  X\        J d   \        WW#R7      # \        WW#R7      # )aˆ  
Concatenate several datasets (sources) into a single dataset.

Use axis=0 to concatenate vertically (default), or axis=1 to concatenate horizontally.

Note for iterable datasets:

* if axis=0, the resulting dataset's `num_shards` is the sum of each dataset's `num_shards`.
* if axis=1, the resulting dataset has one (1) shard to not misalign data.

Args:
    dsets (`List[datasets.Dataset]` or `List[datasets.IterableDataset]`):
        List of Datasets to concatenate.
    info (`DatasetInfo`, *optional*):
        Dataset information, like description, citation, etc.
    split (`NamedSplit`, *optional*):
        Name of the dataset split.
    axis (`{0, 1}`, defaults to `0`):
        Axis to concatenate over, where `0` means over rows (vertically) and `1` means over columns
        (horizontally).

        <Added version="1.6.0"/>

Example:

```py
>>> ds3 = concatenate_datasets([ds1, ds2])
```
z0Unable to concatenate an empty list of datasets.r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   )r   r   rC   )r5   r6   r7   r   r   r   r	   r   r8   r9   r:   r;   r   r   )rB   r   r   rC   r<   r=   r>   r?   s   &&&&    r#   Úconcatenate_datasetsrE   ¨   s¥  € ÷H ÜÐKÓLÐLÜ ×&‰
ˆÜ˜'¤G¬_Ð#=×>Ò>Ü˜'¤KÔ1DÐ#E×FÒFßÜ$Ø{Ð|}Ð{~ð :ð :óð ô !Ø*¨1¨#Ð-FÄtÈGÃ}Àoð VdÜdhÔimÐnuÓivÓdwÐcxÐxzð|óð ô ØsÐtuÐsvÐv|ô  ~Bð  CJó  ~K÷  ~Tñ  ~Tð  }Uð  UVð  Wóð ð �Œ6ä.8¸Ä'×.JÒ.J”œ/Ñ*ÔQ`ÔbiÐPjñ %ˆL™*ô ˜G \×2Ô2ÜØ)¨,×*?Ñ*?Ð)@Ð@XÐYc×YlÑYlÐXmÐm{Ð|}Ð{~ð  Jð  Kóð ñ) 'ð. ”wÓÜ.¨uÀuÔXÐXä-¨eÀeÔWÐWr%   )NNNNr   )NNr   )Útypingr   r   r3   r   r   r   Údataset_dictr   r	   r   r
   r4   r   r   r   Úsplitsr   Úutilsr   Úutils.py_utilsr   Ú
get_loggerr;   Úloggerr   r@   rE   © r%   r#   Ú<module>rN      sZ   ðß $ç cÑ cß :Ý ß lÑ lÝ Ý Ý #ð 
×	Ò	˜HÓ	%€ñ �m W¨oÓ>€÷S
÷l@Xñ @Xr%   