


"""simple docstring"""


import unittest

from transformers import CamembertTokenizer, CamembertTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow
from transformers.utils import is_torch_available

from ...test_tokenization_common import TokenizerTesterMixin


a_       							=    get_tests_dir("fixtures/test_sentencepiece.model")
a_       							=    get_tests_dir("fixtures/test_sentencepiece_bpe.model")

a_       							=    "pt" if is_torch_available() else "tf"
@require_sentencepiece
@require_tokenizers
class snake_case      (  _UpperCamelCase     ,				unittest.TestCase):
		__UpperCamelCase           =			CamembertTokenizer
		__UpperCamelCase           =			CamembertTokenizerFast
		__UpperCamelCase           =			True
		__UpperCamelCase           =			True







		def  a_ (					self      :       List[str]		)       ->						Any:





						'''simple docstring'''







						super().setUp()

						# We have a SentencePiece fixture for testing
						_A					  =			CamembertTokenizer(a__		)
						tokenizer.save_pretrained(self.tmpdirname		)







		def  a_ (					self      :       Optional[Any]		)       ->						Tuple:





						'''simple docstring'''







						_A					  =			"<pad>"
						_A					  =			1

						self.assertEqual(self.get_tokenizer()._convert_token_to_id(a__		)    ,   a__		)
						self.assertEqual(self.get_tokenizer()._convert_id_to_token(a__		)    ,   a__		)







		def  a_ (					self      :       Tuple		)       ->						List[str]:





						'''simple docstring'''







						_A					  =			list(self.get_tokenizer().get_vocab().keys()		)

						self.assertEqual(vocab_keys[0]    ,   "<s>NOTUSED"		)
						self.assertEqual(vocab_keys[1]    ,   "<pad>"		)
						self.assertEqual(vocab_keys[-1]    ,   "<mask>"		)
						self.assertEqual(len(a__		)    ,   10_04		)







		def  a_ (					self      :       List[str]		)       ->						Any:





						'''simple docstring'''







						self.assertEqual(self.get_tokenizer().vocab_size    ,   10_05		)







		def  a_ (					self      :       Optional[int]		)       ->						List[Any]:





						'''simple docstring'''







						_A					  =			CamembertTokenizer(a__		)
						tokenizer.save_pretrained(self.tmpdirname		)
						_A					  =			CamembertTokenizerFast.from_pretrained(self.tmpdirname		)

						_A					  =			"I was born in 92000, and this is falsé."

						_A					  =			tokenizer.encode(a__		)
						_A					  =			rust_tokenizer.encode(a__		)
						self.assertListEqual(a__    ,   a__		)

						_A					  =			tokenizer.encode(a__    ,   add_special_tokens=a__		)
						_A					  =			rust_tokenizer.encode(a__    ,   add_special_tokens=a__		)
						self.assertListEqual(a__    ,   a__		)

						# <unk> tokens are not the same for `rust` than for `slow`.
						# Because spm gives back raw token instead of `unk` in EncodeAsPieces
						# tokens = tokenizer.tokenize(sequence)
						_A					  =			tokenizer.convert_ids_to_tokens(a__		)
						_A					  =			rust_tokenizer.tokenize(a__		)
						self.assertListEqual(a__    ,   a__		)







		def  a_ (					self      :       Tuple		)       ->						List[str]:





						'''simple docstring'''







						if not self.test_rust_tokenizer:
										return

						_A					  =			self.get_tokenizer()
						_A					  =			self.get_rust_tokenizer()

						_A					  =			"I was born in 92000, and this is falsé."

						_A					  =			tokenizer.tokenize(a__		)
						_A					  =			rust_tokenizer.tokenize(a__		)
						self.assertListEqual(a__    ,   a__		)

						_A					  =			tokenizer.encode(a__    ,   add_special_tokens=a__		)
						_A					  =			rust_tokenizer.encode(a__    ,   add_special_tokens=a__		)
						self.assertListEqual(a__    ,   a__		)

						_A					  =			self.get_rust_tokenizer()
						_A					  =			tokenizer.encode(a__		)
						_A					  =			rust_tokenizer.encode(a__		)
						self.assertListEqual(a__    ,   a__		)







		@slow
		def  a_ (					self      :       Union[str, Any]		)       ->						int:





						'''simple docstring'''







						_A					  =			{"input_ids": [[5, 54, 71_96, 2_97, 30, 23, 7_76, 18, 11, 32_15, 37_05, 82_52, 22, 31_64, 11_81, 21_16, 29, 16, 8_13, 25, 7_91, 33_14, 20, 34_46, 38, 2_75_75, 1_20, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [5, 4_68, 17, 11, 90_88, 20, 15_17, 8, 2_28_04, 1_88_18, 10, 38, 6_29, 6_07, 6_07, 1_42, 19, 71_96, 8_67, 56, 1_03_26, 24, 22_67, 20, 4_16, 50_72, 1_56_12, 2_33, 7_34, 7, 23_99, 27, 16, 30_15, 16_49, 7, 24, 20, 43_38, 23_99, 27, 13, 34_00, 14, 13, 61_89, 8, 9_30, 9, 6]], "attention_mask": [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]}  # noqa: E501
						# fmt: on

						# camembert is a french model. So we also use french texts.
						_A					  =			[
						    "Le transformeur est un modèle d'apprentissage profond introduit en 2017, "
						    "utilisé principalement dans le domaine du traitement automatique des langues (TAL).",
						    "À l'instar des réseaux de neurones récurrents (RNN), les transformeurs sont conçus "
						    "pour gérer des données séquentielles, telles que le langage naturel, pour des tâches "
						    "telles que la traduction et la synthèse de texte.",
						]

						self.tokenizer_integration_test_util(
						    expected_encoding=a__    ,   model_name="camembert-base"    ,   revision="3a0641d9a1aeb7e848a74299e7e4c4bca216b4cf"    ,   sequences=a__    ,   )



"""simple docstring"""


import random
import unittest

from torch.utils.data import BatchSampler, DataLoader, IterableDataset

from accelerate import Accelerator
from accelerate.data_loader import (
    BatchSamplerShard,
    DataLoaderDispatcher,
    DataLoaderShard,
    IterableDatasetShard,
    SkipBatchSampler,
    SkipDataLoader,
    skip_first_batches,
)
class snake_case      (  _UpperCamelCase):







		def __init__(					self      :       Optional[int]    ,   a__      :       str=0.0_1    ,   a__      :       str=10_00		)       ->						int:





						'''simple docstring'''







						_A					  =			p_stop
						_A					  =			max_length







		def __iter__(					self      :       Any		)       ->						Optional[Any]:





						'''simple docstring'''







						_A					  =			0
						_A					  =			False
						while not stop and count < self.max_length:
										yield count
										count += 1
										_A					  =			random.random() < self.p_stop





class snake_case      (  unittest.TestCase):







		def  a_ (					self      :       List[Any]    ,   a__      :       Union[str, Any]    ,   a__      :       Union[str, Any]    ,   a__      :       List[str]=False    ,   a__      :       str=True		)       ->						Union[str, Any]:





						'''simple docstring'''







						_A					  =			[
						    BatchSamplerShard(a__    ,   2    ,   a__    ,   split_batches=a__    ,   even_batches=a__		)
						    for i in range(2		)
						]
						_A					  =			[list(a__		) for batch_sampler_shard in batch_sampler_shards]
						if not split_batches:
										self.assertListEqual([len(a__		) for shard in batch_sampler_shards]    ,   [len(a__		) for e in expected]		)
						self.assertListEqual(a__    ,   a__		)







		def  a_ (					self      :       List[Any]		)       ->						str:





						'''simple docstring'''







						_A					  =			BatchSampler(range(24		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1, 2], [6, 7, 8], [12, 13, 14], [18, 19, 20]],
						    [[3, 4, 5], [9, 10, 11], [15, 16, 17], [21, 22, 23]],
						]
						self.check_batch_sampler_shards(a__    ,   a__		)

						_A					  =			BatchSampler(range(24		)    ,   batch_size=3    ,   drop_last=a__		)
						# Expected shouldn't change
						self.check_batch_sampler_shards(a__    ,   a__		)

						# Check the shards when the dataset is a round multiple of batch size but not total batch size.
						_A					  =			BatchSampler(range(21		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1, 2], [6, 7, 8], [12, 13, 14], [18, 19, 20]],
						    [[3, 4, 5], [9, 10, 11], [15, 16, 17], [0, 1, 2]],
						]
						self.check_batch_sampler_shards(a__    ,   a__		)

						_A					  =			BatchSampler(range(21		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1, 2], [6, 7, 8], [12, 13, 14]],
						    [[3, 4, 5], [9, 10, 11], [15, 16, 17]],
						]
						self.check_batch_sampler_shards(a__    ,   a__		)

						# Check the shards when the dataset is not a round multiple of batch size but has a multiple of
						# num_processes batch.
						_A					  =			BatchSampler(range(22		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1, 2], [6, 7, 8], [12, 13, 14], [18, 19, 20]],
						    [[3, 4, 5], [9, 10, 11], [15, 16, 17], [21, 0, 1]],
						]
						self.check_batch_sampler_shards(a__    ,   a__		)

						_A					  =			BatchSampler(range(22		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1, 2], [6, 7, 8], [12, 13, 14]],
						    [[3, 4, 5], [9, 10, 11], [15, 16, 17]],
						]
						self.check_batch_sampler_shards(a__    ,   a__		)

						# Check the shards when the dataset is not a round multiple of batch size but and has not a multiple of
						# num_processes batch.
						_A					  =			BatchSampler(range(20		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1, 2], [6, 7, 8], [12, 13, 14], [18, 19, 0]],
						    [[3, 4, 5], [9, 10, 11], [15, 16, 17], [1, 2, 3]],
						]
						self.check_batch_sampler_shards(a__    ,   a__		)

						_A					  =			BatchSampler(range(20		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1, 2], [6, 7, 8], [12, 13, 14]],
						    [[3, 4, 5], [9, 10, 11], [15, 16, 17]],
						]
						self.check_batch_sampler_shards(a__    ,   a__		)

						# Check the shards when the dataset is very small.
						_A					  =			BatchSampler(range(2		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[[[0, 1, 0]], [[1, 0, 1]]]
						self.check_batch_sampler_shards(a__    ,   a__		)

						_A					  =			BatchSampler(range(2		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[[], []]
						self.check_batch_sampler_shards(a__    ,   a__		)







		def  a_ (					self      :       int		)       ->						int:





						'''simple docstring'''







						_A					  =			BatchSampler(range(24		)    ,   batch_size=4    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1], [4, 5], [8, 9], [12, 13], [16, 17], [20, 21]],
						    [[2, 3], [6, 7], [10, 11], [14, 15], [18, 19], [22, 23]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   split_batches=a__		)

						_A					  =			BatchSampler(range(24		)    ,   batch_size=4    ,   drop_last=a__		)
						# Expected shouldn't change
						self.check_batch_sampler_shards(a__    ,   a__    ,   split_batches=a__		)

						# Check the shards when the dataset is not a round multiple of batch size.
						_A					  =			BatchSampler(range(22		)    ,   batch_size=4    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1], [4, 5], [8, 9], [12, 13], [16, 17], [20, 21]],
						    [[2, 3], [6, 7], [10, 11], [14, 15], [18, 19], [0, 1]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   split_batches=a__		)

						_A					  =			BatchSampler(range(22		)    ,   batch_size=4    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1], [4, 5], [8, 9], [12, 13], [16, 17]],
						    [[2, 3], [6, 7], [10, 11], [14, 15], [18, 19]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   split_batches=a__		)

						# Check the shards when the dataset is not a round multiple of batch size or num_processes.
						_A					  =			BatchSampler(range(21		)    ,   batch_size=4    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1], [4, 5], [8, 9], [12, 13], [16, 17], [20, 0]],
						    [[2, 3], [6, 7], [10, 11], [14, 15], [18, 19], [1, 2]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   split_batches=a__		)

						_A					  =			BatchSampler(range(21		)    ,   batch_size=4    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1], [4, 5], [8, 9], [12, 13], [16, 17]],
						    [[2, 3], [6, 7], [10, 11], [14, 15], [18, 19]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   split_batches=a__		)

						# Check the shards when the dataset is very small.
						_A					  =			BatchSampler(range(2		)    ,   batch_size=4    ,   drop_last=a__		)
						_A					  =			[[[0, 1]], [[0, 1]]]
						self.check_batch_sampler_shards(a__    ,   a__    ,   split_batches=a__		)

						_A					  =			BatchSampler(range(2		)    ,   batch_size=4    ,   drop_last=a__		)
						_A					  =			[[], []]
						self.check_batch_sampler_shards(a__    ,   a__    ,   split_batches=a__		)







		def  a_ (					self      :       List[str]		)       ->						List[str]:





						'''simple docstring'''







						_A					  =			BatchSampler(range(24		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1, 2], [6, 7, 8], [12, 13, 14], [18, 19, 20]],
						    [[3, 4, 5], [9, 10, 11], [15, 16, 17], [21, 22, 23]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   even_batches=a__		)

						_A					  =			BatchSampler(range(24		)    ,   batch_size=3    ,   drop_last=a__		)
						# Expected shouldn't change
						self.check_batch_sampler_shards(a__    ,   a__    ,   even_batches=a__		)

						# Check the shards when the dataset is a round multiple of batch size but not total batch size.
						_A					  =			BatchSampler(range(21		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1, 2], [6, 7, 8], [12, 13, 14], [18, 19, 20]],
						    [[3, 4, 5], [9, 10, 11], [15, 16, 17]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   even_batches=a__		)

						_A					  =			BatchSampler(range(21		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1, 2], [6, 7, 8], [12, 13, 14]],
						    [[3, 4, 5], [9, 10, 11], [15, 16, 17]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   even_batches=a__		)

						# Check the shards when the dataset is not a round multiple of batch size but has a multiple of
						# num_processes batch.
						_A					  =			BatchSampler(range(22		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1, 2], [6, 7, 8], [12, 13, 14], [18, 19, 20]],
						    [[3, 4, 5], [9, 10, 11], [15, 16, 17], [21]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   even_batches=a__		)

						_A					  =			BatchSampler(range(22		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1, 2], [6, 7, 8], [12, 13, 14]],
						    [[3, 4, 5], [9, 10, 11], [15, 16, 17]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   even_batches=a__		)

						# Check the shards when the dataset is not a round multiple of batch size but and has not a multiple of
						# num_processes batch.
						_A					  =			BatchSampler(range(20		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1, 2], [6, 7, 8], [12, 13, 14], [18, 19]],
						    [[3, 4, 5], [9, 10, 11], [15, 16, 17]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   even_batches=a__		)

						_A					  =			BatchSampler(range(20		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1, 2], [6, 7, 8], [12, 13, 14]],
						    [[3, 4, 5], [9, 10, 11], [15, 16, 17]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   even_batches=a__		)

						# Check the shards when the dataset is very small.
						_A					  =			BatchSampler(range(2		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[[[0, 1]], []]
						self.check_batch_sampler_shards(a__    ,   a__    ,   even_batches=a__		)

						_A					  =			BatchSampler(range(2		)    ,   batch_size=3    ,   drop_last=a__		)
						_A					  =			[[], []]
						self.check_batch_sampler_shards(a__    ,   a__    ,   even_batches=a__		)







		def  a_ (					self      :       List[str]		)       ->						str:





						'''simple docstring'''







						_A					  =			BatchSampler(range(24		)    ,   batch_size=4    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1], [4, 5], [8, 9], [12, 13], [16, 17], [20, 21]],
						    [[2, 3], [6, 7], [10, 11], [14, 15], [18, 19], [22, 23]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   split_batches=a__    ,   even_batches=a__		)

						_A					  =			BatchSampler(range(24		)    ,   batch_size=4    ,   drop_last=a__		)
						# Expected shouldn't change
						self.check_batch_sampler_shards(a__    ,   a__    ,   split_batches=a__    ,   even_batches=a__		)

						# Check the shards when the dataset is not a round multiple of batch size.
						_A					  =			BatchSampler(range(22		)    ,   batch_size=4    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1], [4, 5], [8, 9], [12, 13], [16, 17], [20, 21]],
						    [[2, 3], [6, 7], [10, 11], [14, 15], [18, 19]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   split_batches=a__    ,   even_batches=a__		)

						_A					  =			BatchSampler(range(22		)    ,   batch_size=4    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1], [4, 5], [8, 9], [12, 13], [16, 17]],
						    [[2, 3], [6, 7], [10, 11], [14, 15], [18, 19]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   split_batches=a__    ,   even_batches=a__		)

						# Check the shards when the dataset is not a round multiple of batch size or num_processes.
						_A					  =			BatchSampler(range(21		)    ,   batch_size=4    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1], [4, 5], [8, 9], [12, 13], [16, 17], [20]],
						    [[2, 3], [6, 7], [10, 11], [14, 15], [18, 19]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   split_batches=a__    ,   even_batches=a__		)

						_A					  =			BatchSampler(range(21		)    ,   batch_size=4    ,   drop_last=a__		)
						_A					  =			[
						    [[0, 1], [4, 5], [8, 9], [12, 13], [16, 17]],
						    [[2, 3], [6, 7], [10, 11], [14, 15], [18, 19]],
						]
						self.check_batch_sampler_shards(a__    ,   a__    ,   split_batches=a__    ,   even_batches=a__		)

						# Check the shards when the dataset is very small.
						_A					  =			BatchSampler(range(2		)    ,   batch_size=4    ,   drop_last=a__		)
						_A					  =			[[[0, 1]], []]
						self.check_batch_sampler_shards(a__    ,   a__    ,   split_batches=a__    ,   even_batches=a__		)

						_A					  =			BatchSampler(range(2		)    ,   batch_size=4    ,   drop_last=a__		)
						_A					  =			[[], []]
						self.check_batch_sampler_shards(a__    ,   a__    ,   split_batches=a__    ,   even_batches=a__		)







		def  a_ (					self      :       Union[str, Any]		)       ->						str:





						'''simple docstring'''







						_A					  =			[[0, 1, 2], [3, 4], [5, 6, 7, 8], [9, 10, 11], [12, 13]]
						_A					  =			[BatchSamplerShard(a__    ,   2    ,   a__    ,   even_batches=a__		) for i in range(2		)]

						self.assertEqual(len(batch_sampler_shards[0]		)    ,   3		)
						self.assertEqual(len(batch_sampler_shards[1]		)    ,   2		)

						self.assertListEqual(list(batch_sampler_shards[0]		)    ,   [[0, 1, 2], [5, 6, 7, 8], [12, 13]]		)
						self.assertListEqual(list(batch_sampler_shards[1]		)    ,   [[3, 4], [9, 10, 11]]		)







		def  a_ (					self      :       Optional[int]    ,   a__      :       Optional[int]    ,   a__      :       Tuple    ,   a__      :       Optional[int]    ,   a__      :       Union[str, Any]=False    ,   a__      :       int=2    ,   a__      :       List[Any]=False		)       ->						str:





						'''simple docstring'''







						random.seed(a__		)
						_A					  =			list(a__		)

						_A					  =			[
						    IterableDatasetShard(
						        a__    ,   batch_size=a__    ,   drop_last=a__    ,   num_processes=a__    ,   process_index=a__    ,   split_batches=a__    ,   )
						    for i in range(a__		)
						]
						_A					  =			[]
						for iterable_dataset_shard in iterable_dataset_shards:
										# Since our random iterable dataset will be... random... we need to use a seed to get reproducible results.
										random.seed(a__		)
										iterable_dataset_lists.append(list(a__		)		)

						_A					  =			batch_size // num_processes if split_batches else batch_size
						# All iterable dataset shard should have the same length, a round multiple of shard_batch_size
						_A					  =			iterable_dataset_lists[0]
						for l in iterable_dataset_lists[1:]:
										self.assertEqual(len(a__		)    ,   len(a__		)		)
										self.assertTrue(len(a__		) % shard_batch_size == 0		)

						_A					  =			[]
						for idx in range(0    ,   len(a__		)    ,   a__		):
										for l in iterable_dataset_lists:
														observed += l[idx : idx + shard_batch_size]

						if not drop_last:
										while len(a__		) < len(a__		):
														reference += reference
						self.assertListEqual(a__    ,   reference[: len(a__		)]		)







		def  a_ (					self      :       List[str]		)       ->						List[Any]:





						'''simple docstring'''







						_A					  =			42
						_A					  =			RandomIterableDataset()

						self.check_iterable_dataset_shards(a__    ,   a__    ,   batch_size=4    ,   drop_last=a__    ,   split_batches=a__		)
						self.check_iterable_dataset_shards(a__    ,   a__    ,   batch_size=4    ,   drop_last=a__    ,   split_batches=a__		)
						self.check_iterable_dataset_shards(a__    ,   a__    ,   batch_size=4    ,   drop_last=a__    ,   split_batches=a__		)
						self.check_iterable_dataset_shards(a__    ,   a__    ,   batch_size=4    ,   drop_last=a__    ,   split_batches=a__		)

						# Edge case with a very small dataset
						_A					  =			RandomIterableDataset(max_length=2		)

						self.check_iterable_dataset_shards(a__    ,   a__    ,   batch_size=4    ,   drop_last=a__    ,   split_batches=a__		)
						self.check_iterable_dataset_shards(a__    ,   a__    ,   batch_size=4    ,   drop_last=a__    ,   split_batches=a__		)
						self.check_iterable_dataset_shards(a__    ,   a__    ,   batch_size=4    ,   drop_last=a__    ,   split_batches=a__		)
						self.check_iterable_dataset_shards(a__    ,   a__    ,   batch_size=4    ,   drop_last=a__    ,   split_batches=a__		)







		def  a_ (					self      :       List[str]		)       ->						Dict:





						'''simple docstring'''







						_A					  =			BatchSampler(range(16		)    ,   batch_size=4    ,   drop_last=a__		)
						_A					  =			SkipBatchSampler(a__    ,   2		)
						self.assertListEqual(list(a__		)    ,   [[8, 9, 10, 11], [12, 13, 14, 15]]		)







		def  a_ (					self      :       int		)       ->						Union[str, Any]:





						'''simple docstring'''







						_A					  =			SkipDataLoader(list(range(16		)		)    ,   batch_size=4    ,   skip_batches=2		)
						self.assertListEqual([t.tolist() for t in dataloader]    ,   [[8, 9, 10, 11], [12, 13, 14, 15]]		)







		def  a_ (					self      :       int		)       ->						Optional[int]:





						'''simple docstring'''







						_A					  =			DataLoader(list(range(16		)		)    ,   batch_size=4		)
						_A					  =			skip_first_batches(a__    ,   num_batches=2		)
						self.assertListEqual([t.tolist() for t in new_dataloader]    ,   [[8, 9, 10, 11], [12, 13, 14, 15]]		)







		def  a_ (					self      :       Optional[Any]		)       ->						Optional[int]:





						'''simple docstring'''







						_A					  =			DataLoaderShard(list(range(16		)		)    ,   batch_size=4		)
						for idx, _ in enumerate(a__		):
										self.assertEqual(dataloader.end_of_dataloader    ,   idx == 3		)

						# Test it also works on the second iteration
						for idx, _ in enumerate(a__		):
										self.assertEqual(dataloader.end_of_dataloader    ,   idx == 3		)







		def  a_ (					self      :       int		)       ->						int:





						'''simple docstring'''







						Accelerator()
						_A					  =			DataLoaderDispatcher(range(16		)    ,   batch_size=4		)
						for idx, _ in enumerate(a__		):
										self.assertEqual(dataloader.end_of_dataloader    ,   idx == 3		)

						# Test it also works on the second iteration
						for idx, _ in enumerate(a__		):
										self.assertEqual(dataloader.end_of_dataloader    ,   idx == 3		)