


'''simple docstring'''


import os
import unittest

from transformers import ElectraTokenizerFast
from transformers.models.electra.tokenization_electra import (
    VOCAB_FILES_NAMES,
    BasicTokenizer,
    ElectraTokenizer,
    WordpieceTokenizer,
    _is_control,
    _is_punctuation,
    _is_whitespace,
)
from transformers.testing_utils import require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin, filter_non_english






@require_tokenizers
class 						lowerCAmelCase__      (      UpperCAmelCase__     ,							unittest.TestCase						):
			lowerCAmelCase			:						Tuple							 =  ElectraTokenizer
			lowerCAmelCase			:						List[Any]							 =  ElectraTokenizerFast
			lowerCAmelCase			:						List[str]							 =  True
			lowerCAmelCase			:						Optional[Any]							 =  True
			lowerCAmelCase			:						Dict							 =  filter_non_english




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



					'''simple docstring'''







					super().setUp()

					_UpperCAmelCase		:							int             =   [
					    "[UNK]",
					    "[CLS]",
					    "[SEP]",
					    "[PAD]",
					    "[MASK]",
					    "want",
					    "##want",
					    "##ed",
					    "wa",
					    "un",
					    "runn",
					    "##ing",
					    ",",
					    "low",
					    "lowest",
					]
					_UpperCAmelCase		:							Union[str, Any]             =   os.path.join(self.tmpdirname						,	VOCAB_FILES_NAMES["vocab_file"]			)
					with open(self.vocab_file						,	"w"						,	encoding="utf-8"			) as vocab_writer:
							vocab_writer.write("".join([x + "\n" for x in vocab_tokens]			)			)




			def 				lowerCAmelCase__     (		self	:  List[str]						,	lowerCamelCase__	:  List[Any]			) ->Tuple:



					'''simple docstring'''







					_UpperCAmelCase		:							Union[str, Any]             =   "UNwant\u00E9d,running"
					_UpperCAmelCase		:							Optional[Any]             =   "unwanted, running"
					return input_text, output_text




			def 				lowerCAmelCase__     (		self	:  Dict			) ->List[Any]:



					'''simple docstring'''







					_UpperCAmelCase		:							Optional[Any]             =   self.tokenizer_class(self.vocab_file			)

					_UpperCAmelCase		:							Any             =   tokenizer.tokenize("UNwant\u00E9d,running"			)
					self.assertListEqual(lowerCamelCase__						,	["un", "##want", "##ed", ",", "runn", "##ing"]			)
					self.assertListEqual(tokenizer.convert_tokens_to_ids(lowerCamelCase__			)						,	[9, 6, 7, 12, 10, 11]			)




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



					'''simple docstring'''







					if not self.test_rust_tokenizer:
							return

					_UpperCAmelCase		:							List[Any]             =   self.get_tokenizer()
					_UpperCAmelCase		:							int             =   self.get_rust_tokenizer()

					_UpperCAmelCase		:							Optional[int]             =   "UNwant\u00E9d,running"

					_UpperCAmelCase		:							Any             =   tokenizer.tokenize(lowerCamelCase__			)
					_UpperCAmelCase		:							Dict             =   rust_tokenizer.tokenize(lowerCamelCase__			)
					self.assertListEqual(lowerCamelCase__						,	lowerCamelCase__			)

					_UpperCAmelCase		:							List[Any]             =   tokenizer.encode(lowerCamelCase__						,	add_special_tokens=lowerCamelCase__			)
					_UpperCAmelCase		:							Optional[int]             =   rust_tokenizer.encode(lowerCamelCase__						,	add_special_tokens=lowerCamelCase__			)
					self.assertListEqual(lowerCamelCase__						,	lowerCamelCase__			)

					_UpperCAmelCase		:							Tuple             =   self.get_rust_tokenizer()
					_UpperCAmelCase		:							List[str]             =   tokenizer.encode(lowerCamelCase__			)
					_UpperCAmelCase		:							Union[str, Any]             =   rust_tokenizer.encode(lowerCamelCase__			)
					self.assertListEqual(lowerCamelCase__						,	lowerCamelCase__			)

					# With lower casing
					_UpperCAmelCase		:							Tuple             =   self.get_tokenizer(do_lower_case=lowerCamelCase__			)
					_UpperCAmelCase		:							Union[str, Any]             =   self.get_rust_tokenizer(do_lower_case=lowerCamelCase__			)

					_UpperCAmelCase		:							Tuple             =   "UNwant\u00E9d,running"

					_UpperCAmelCase		:							Dict             =   tokenizer.tokenize(lowerCamelCase__			)
					_UpperCAmelCase		:							Dict             =   rust_tokenizer.tokenize(lowerCamelCase__			)
					self.assertListEqual(lowerCamelCase__						,	lowerCamelCase__			)

					_UpperCAmelCase		:							Union[str, Any]             =   tokenizer.encode(lowerCamelCase__						,	add_special_tokens=lowerCamelCase__			)
					_UpperCAmelCase		:							str             =   rust_tokenizer.encode(lowerCamelCase__						,	add_special_tokens=lowerCamelCase__			)
					self.assertListEqual(lowerCamelCase__						,	lowerCamelCase__			)

					_UpperCAmelCase		:							List[Any]             =   self.get_rust_tokenizer()
					_UpperCAmelCase		:							Optional[Any]             =   tokenizer.encode(lowerCamelCase__			)
					_UpperCAmelCase		:							Dict             =   rust_tokenizer.encode(lowerCamelCase__			)
					self.assertListEqual(lowerCamelCase__						,	lowerCamelCase__			)




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



					'''simple docstring'''







					_UpperCAmelCase		:							List[Any]             =   BasicTokenizer()

					self.assertListEqual(tokenizer.tokenize("ah\u535A\u63A8zz"			)						,	["ah", "\u535A", "\u63A8", "zz"]			)




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



					'''simple docstring'''







					_UpperCAmelCase		:							List[str]             =   BasicTokenizer(do_lower_case=lowerCamelCase__			)

					self.assertListEqual(
					    tokenizer.tokenize(" \tHeLLo!how  \n Are yoU?  "			)						,	["hello", "!", "how", "are", "you", "?"]			)
					self.assertListEqual(tokenizer.tokenize("H\u00E9llo"			)						,	["hello"]			)




			def 				lowerCAmelCase__     (		self	:  str			) ->int:



					'''simple docstring'''







					_UpperCAmelCase		:							str             =   BasicTokenizer(do_lower_case=lowerCamelCase__						,	strip_accents=lowerCamelCase__			)

					self.assertListEqual(
					    tokenizer.tokenize(" \tHäLLo!how  \n Are yoU?  "			)						,	["hällo", "!", "how", "are", "you", "?"]			)
					self.assertListEqual(tokenizer.tokenize("H\u00E9llo"			)						,	["h\u00E9llo"]			)




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



					'''simple docstring'''







					_UpperCAmelCase		:							Optional[int]             =   BasicTokenizer(do_lower_case=lowerCamelCase__						,	strip_accents=lowerCamelCase__			)

					self.assertListEqual(
					    tokenizer.tokenize(" \tHäLLo!how  \n Are yoU?  "			)						,	["hallo", "!", "how", "are", "you", "?"]			)
					self.assertListEqual(tokenizer.tokenize("H\u00E9llo"			)						,	["hello"]			)




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



					'''simple docstring'''







					_UpperCAmelCase		:							Dict             =   BasicTokenizer(do_lower_case=lowerCamelCase__			)

					self.assertListEqual(
					    tokenizer.tokenize(" \tHäLLo!how  \n Are yoU?  "			)						,	["hallo", "!", "how", "are", "you", "?"]			)
					self.assertListEqual(tokenizer.tokenize("H\u00E9llo"			)						,	["hello"]			)




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



					'''simple docstring'''







					_UpperCAmelCase		:							Optional[Any]             =   BasicTokenizer(do_lower_case=lowerCamelCase__			)

					self.assertListEqual(
					    tokenizer.tokenize(" \tHeLLo!how  \n Are yoU?  "			)						,	["HeLLo", "!", "how", "Are", "yoU", "?"]			)




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



					'''simple docstring'''







					_UpperCAmelCase		:							Optional[int]             =   BasicTokenizer(do_lower_case=lowerCamelCase__						,	strip_accents=lowerCamelCase__			)

					self.assertListEqual(
					    tokenizer.tokenize(" \tHäLLo!how  \n Are yoU?  "			)						,	["HäLLo", "!", "how", "Are", "yoU", "?"]			)




			def 				lowerCAmelCase__     (		self	:  Tuple			) ->Optional[int]:



					'''simple docstring'''







					_UpperCAmelCase		:							Optional[int]             =   BasicTokenizer(do_lower_case=lowerCamelCase__						,	strip_accents=lowerCamelCase__			)

					self.assertListEqual(
					    tokenizer.tokenize(" \tHäLLo!how  \n Are yoU?  "			)						,	["HaLLo", "!", "how", "Are", "yoU", "?"]			)




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



					'''simple docstring'''







					_UpperCAmelCase		:							Tuple             =   BasicTokenizer(do_lower_case=lowerCamelCase__						,	never_split=["[UNK]"]			)

					self.assertListEqual(
					    tokenizer.tokenize(" \tHeLLo!how  \n Are yoU? [UNK]"			)						,	["HeLLo", "!", "how", "Are", "yoU", "?", "[UNK]"]			)




			def 				lowerCAmelCase__     (		self	:  Optional[int]			) ->Tuple:



					'''simple docstring'''







					_UpperCAmelCase		:							Any             =   ["[UNK]", "[CLS]", "[SEP]", "want", "##want", "##ed", "wa", "un", "runn", "##ing"]

					_UpperCAmelCase		:							List[Any]             =   {}
					for i, token in enumerate(lowerCamelCase__			):
							_UpperCAmelCase		:							Any             =   i
					_UpperCAmelCase		:							Optional[Any]             =   WordpieceTokenizer(vocab=lowerCamelCase__						,	unk_token="[UNK]"			)

					self.assertListEqual(tokenizer.tokenize(""			)						,	[]			)

					self.assertListEqual(tokenizer.tokenize("unwanted running"			)						,	["un", "##want", "##ed", "runn", "##ing"]			)

					self.assertListEqual(tokenizer.tokenize("unwantedX running"			)						,	["[UNK]", "runn", "##ing"]			)




			def 				lowerCAmelCase__     (		self	:  Dict			) ->Any:



					'''simple docstring'''







					self.assertTrue(_is_whitespace(" "			)			)
					self.assertTrue(_is_whitespace("\t"			)			)
					self.assertTrue(_is_whitespace("\r"			)			)
					self.assertTrue(_is_whitespace("\n"			)			)
					self.assertTrue(_is_whitespace("\u00A0"			)			)

					self.assertFalse(_is_whitespace("A"			)			)
					self.assertFalse(_is_whitespace("-"			)			)




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



					'''simple docstring'''







					self.assertTrue(_is_control("\u0005"			)			)

					self.assertFalse(_is_control("A"			)			)
					self.assertFalse(_is_control(" "			)			)
					self.assertFalse(_is_control("\t"			)			)
					self.assertFalse(_is_control("\r"			)			)




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



					'''simple docstring'''







					self.assertTrue(_is_punctuation("-"			)			)
					self.assertTrue(_is_punctuation("$"			)			)
					self.assertTrue(_is_punctuation("`"			)			)
					self.assertTrue(_is_punctuation("."			)			)

					self.assertFalse(_is_punctuation("A"			)			)
					self.assertFalse(_is_punctuation(" "			)			)




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



					'''simple docstring'''







					_UpperCAmelCase		:							Optional[int]             =   self.get_tokenizer()
					_UpperCAmelCase		:							List[str]             =   self.get_rust_tokenizer()

					# Example taken from the issue https://github.com/huggingface/tokenizers/issues/340
					self.assertListEqual([tokenizer.tokenize(lowerCamelCase__			) for t in ["Test", "\xad", "test"]]						,	[["[UNK]"], [], ["[UNK]"]]			)

					self.assertListEqual(
					    [rust_tokenizer.tokenize(lowerCamelCase__			) for t in ["Test", "\xad", "test"]]						,	[["[UNK]"], [], ["[UNK]"]]			)




			@slow
			def 				lowerCAmelCase__     (		self	:  Tuple			) ->List[Any]:



					'''simple docstring'''







					_UpperCAmelCase		:							Optional[int]             =   self.tokenizer_class.from_pretrained("google/electra-base-discriminator"			)

					_UpperCAmelCase		:							Any             =   tokenizer.encode("sequence builders"						,	add_special_tokens=lowerCamelCase__			)
					_UpperCAmelCase		:							List[Any]             =   tokenizer.encode("multi-sequence build"						,	add_special_tokens=lowerCamelCase__			)

					_UpperCAmelCase		:							str             =   tokenizer.build_inputs_with_special_tokens(lowerCamelCase__			)
					_UpperCAmelCase		:							List[str]             =   tokenizer.build_inputs_with_special_tokens(lowerCamelCase__						,	lowerCamelCase__			)

					assert encoded_sentence == [1_01] + text + [1_02]
					assert encoded_pair == [1_01] + text + [1_02] + text_a + [1_02]




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



					'''simple docstring'''







					for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
							with self.subTest(F"""{tokenizer.__class__.__name__} ({pretrained_name})"""			):
									_UpperCAmelCase		:							Any             =   self.rust_tokenizer_class.from_pretrained(lowerCamelCase__						,	**lowerCamelCase__			)

									_UpperCAmelCase		:							Dict             =   F"""A, naïve {tokenizer_r.mask_token} AllenNLP sentence."""
									_UpperCAmelCase		:							Optional[Any]             =   tokenizer_r.encode_plus(
									    lowerCamelCase__						,	return_attention_mask=lowerCamelCase__						,	return_token_type_ids=lowerCamelCase__						,	return_offsets_mapping=lowerCamelCase__						,	add_special_tokens=lowerCamelCase__						,	)

									_UpperCAmelCase		:							Dict             =   tokenizer_r.do_lower_case if hasattr(lowerCamelCase__						,	"do_lower_case"			) else False
									_UpperCAmelCase		:							int             =   (
									    [
									        ((0, 0), tokenizer_r.cls_token),
									        ((0, 1), "A"),
									        ((1, 2), ","),
									        ((3, 5), "na"),
									        ((5, 6), "##ï"),
									        ((6, 8), "##ve"),
									        ((9, 15), tokenizer_r.mask_token),
									        ((16, 21), "Allen"),
									        ((21, 23), "##NL"),
									        ((23, 24), "##P"),
									        ((25, 33), "sentence"),
									        ((33, 34), "."),
									        ((0, 0), tokenizer_r.sep_token),
									    ]
									    if not do_lower_case
									    else [
									        ((0, 0), tokenizer_r.cls_token),
									        ((0, 1), "a"),
									        ((1, 2), ","),
									        ((3, 8), "naive"),
									        ((9, 15), tokenizer_r.mask_token),
									        ((16, 21), "allen"),
									        ((21, 23), "##nl"),
									        ((23, 24), "##p"),
									        ((25, 33), "sentence"),
									        ((33, 34), "."),
									        ((0, 0), tokenizer_r.sep_token),
									    ]
									)

									self.assertEqual(
									    [e[1] for e in expected_results]						,	tokenizer_r.convert_ids_to_tokens(tokens["input_ids"]			)			)
									self.assertEqual([e[0] for e in expected_results]						,	tokens["offset_mapping"]			)






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



					'''simple docstring'''







					_UpperCAmelCase		:							Optional[Any]             =   ["的", "人", "有"]
					_UpperCAmelCase		:							Dict             =   "".join(lowerCamelCase__			)
					for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
							with self.subTest(F"""{tokenizer.__class__.__name__} ({pretrained_name})"""			):
									_UpperCAmelCase		:							Tuple             =   True
									_UpperCAmelCase		:							int             =   self.tokenizer_class.from_pretrained(lowerCamelCase__						,	**lowerCamelCase__			)
									_UpperCAmelCase		:							Union[str, Any]             =   self.rust_tokenizer_class.from_pretrained(lowerCamelCase__						,	**lowerCamelCase__			)

									_UpperCAmelCase		:							int             =   tokenizer_p.encode(lowerCamelCase__						,	add_special_tokens=lowerCamelCase__			)
									_UpperCAmelCase		:							Tuple             =   tokenizer_r.encode(lowerCamelCase__						,	add_special_tokens=lowerCamelCase__			)

									_UpperCAmelCase		:							List[str]             =   tokenizer_r.convert_ids_to_tokens(lowerCamelCase__			)
									_UpperCAmelCase		:							str             =   tokenizer_p.convert_ids_to_tokens(lowerCamelCase__			)

									# it is expected that each Chinese character is not preceded by "##"
									self.assertListEqual(lowerCamelCase__						,	lowerCamelCase__			)
									self.assertListEqual(lowerCamelCase__						,	lowerCamelCase__			)

									_UpperCAmelCase		:							List[str]             =   False
									_UpperCAmelCase		:							Optional[int]             =   self.rust_tokenizer_class.from_pretrained(lowerCamelCase__						,	**lowerCamelCase__			)
									_UpperCAmelCase		:							Optional[Any]             =   self.tokenizer_class.from_pretrained(lowerCamelCase__						,	**lowerCamelCase__			)

									_UpperCAmelCase		:							List[str]             =   tokenizer_r.encode(lowerCamelCase__						,	add_special_tokens=lowerCamelCase__			)
									_UpperCAmelCase		:							Union[str, Any]             =   tokenizer_p.encode(lowerCamelCase__						,	add_special_tokens=lowerCamelCase__			)

									_UpperCAmelCase		:							int             =   tokenizer_r.convert_ids_to_tokens(lowerCamelCase__			)
									_UpperCAmelCase		:							int             =   tokenizer_p.convert_ids_to_tokens(lowerCamelCase__			)

									# it is expected that only the first Chinese character is not preceded by "##".
									_UpperCAmelCase		:							Optional[Any]             =   [
									    F"""##{token}""" if idx != 0 else token for idx, token in enumerate(lowerCamelCase__			)
									]
									self.assertListEqual(lowerCamelCase__						,	lowerCamelCase__			)
									self.assertListEqual(lowerCamelCase__						,	lowerCamelCase__			)







'''simple docstring'''


import os
from argparse import ArgumentParser
from pathlib import Path
from shutil import copyfile
from typing import List

from datasets import config
from datasets.builder import DatasetBuilder
from datasets.commands import BaseDatasetsCLICommand
from datasets.download.download_config import DownloadConfig
from datasets.download.download_manager import DownloadMode
from datasets.load import dataset_module_factory, import_main_class
from datasets.utils.info_utils import VerificationMode






def 			__lowerCAmelCase			(__lowerCAmelCase   ,			**__lowerCAmelCase ):
		return RunBeamCommand(
		    args.dataset   ,			args.name   ,			args.cache_dir   ,			args.beam_pipeline_options   ,			args.data_dir   ,			args.all_configs   ,			args.save_info or args.save_infos   ,			args.ignore_verifications   ,			args.force_redownload   ,			**__lowerCAmelCase   ,			)






class 						lowerCAmelCase__      (      UpperCAmelCase__						):




			@staticmethod
			def 				lowerCAmelCase__     (		lowerCamelCase__	:  ArgumentParser			) ->Optional[Any]:



					'''simple docstring'''







					_UpperCAmelCase		:							Union[str, Any]             =   parser.add_parser("run_beam"						,	help="Run a Beam dataset processing pipeline"			)
					run_beam_parser.add_argument("dataset"						,	type=lowerCamelCase__						,	help="Name of the dataset to download"			)
					run_beam_parser.add_argument("--name"						,	type=lowerCamelCase__						,	default=lowerCamelCase__						,	help="Dataset config name"			)
					run_beam_parser.add_argument(
					    "--cache_dir"						,	type=lowerCamelCase__						,	default=lowerCamelCase__						,	help="Cache directory where the datasets are stored"						,	)
					run_beam_parser.add_argument(
					    "--beam_pipeline_options"						,	type=lowerCamelCase__						,	default=""						,	help="Beam pipeline options, separated by commas. Example:: `--beam_pipeline_options=job_name=my-job,project=my-project`"						,	)
					run_beam_parser.add_argument(
					    "--data_dir"						,	type=lowerCamelCase__						,	default=lowerCamelCase__						,	help="Can be used to specify a manual directory to get the files from"						,	)
					run_beam_parser.add_argument("--all_configs"						,	action="store_true"						,	help="Test all dataset configurations"			)
					run_beam_parser.add_argument("--save_info"						,	action="store_true"						,	help="Save the dataset infos file"			)
					run_beam_parser.add_argument(
					    "--ignore_verifications"						,	action="store_true"						,	help="Run the test without checksums and splits checks"			)
					run_beam_parser.add_argument("--force_redownload"						,	action="store_true"						,	help="Force dataset redownload"			)
					# aliases
					run_beam_parser.add_argument("--save_infos"						,	action="store_true"						,	help="alias for save_info"			)
					run_beam_parser.set_defaults(func=lowerCamelCase__			)




			def __init__(		self	:  str						,	lowerCamelCase__	:  str						,	lowerCamelCase__	:  str						,	lowerCamelCase__	:  str						,	lowerCamelCase__	:  str						,	lowerCamelCase__	:  str						,	lowerCamelCase__	:  bool						,	lowerCamelCase__	:  bool						,	lowerCamelCase__	:  bool						,	lowerCamelCase__	:  bool						,	**lowerCamelCase__	:  Optional[Any]						,	) ->Tuple:



					'''simple docstring'''







					_UpperCAmelCase		:							Any             =   dataset
					_UpperCAmelCase		:							str             =   name
					_UpperCAmelCase		:							int             =   cache_dir
					_UpperCAmelCase		:							Optional[int]             =   beam_pipeline_options
					_UpperCAmelCase		:							int             =   data_dir
					_UpperCAmelCase		:							Optional[int]             =   all_configs
					_UpperCAmelCase		:							Any             =   save_infos
					_UpperCAmelCase		:							Optional[Any]             =   ignore_verifications
					_UpperCAmelCase		:							Any             =   force_redownload
					_UpperCAmelCase		:							Tuple             =   config_kwargs






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



					'''simple docstring'''







					import apache_beam as beam

					if self._name is not None and self._all_configs:
							print("Both parameters `name` and `all_configs` can't be used at once."			)
							exit(1			)
					_UpperCAmelCase       ,     _UpperCAmelCase		:							Union[str, Any]             =   self._dataset, self._name
					_UpperCAmelCase		:							Union[str, Any]             =   dataset_module_factory(lowerCamelCase__			)
					_UpperCAmelCase		:							Any             =   import_main_class(dataset_module.module_path			)
					_UpperCAmelCase		:							List[DatasetBuilder]             =   []
					if self._beam_pipeline_options:
							_UpperCAmelCase		:							Optional[int]             =   beam.options.pipeline_options.PipelineOptions(
							    flags=[F"""--{opt.strip()}""" for opt in self._beam_pipeline_options.split(","			) if opt]			)
					else:
							_UpperCAmelCase		:							str             =   None
					if self._all_configs and len(builder_cls.BUILDER_CONFIGS			) > 0:
							for builder_config in builder_cls.BUILDER_CONFIGS:
									builders.append(
									    builder_cls(
									        config_name=builder_config.name						,	data_dir=self._data_dir						,	hash=dataset_module.hash						,	beam_options=lowerCamelCase__						,	cache_dir=self._cache_dir						,	base_path=dataset_module.builder_kwargs.get("base_path"			)						,	)			)
					else:
							builders.append(
							    builder_cls(
							        config_name=lowerCamelCase__						,	data_dir=self._data_dir						,	beam_options=lowerCamelCase__						,	cache_dir=self._cache_dir						,	base_path=dataset_module.builder_kwargs.get("base_path"			)						,	**self._config_kwargs						,	)			)

					for builder in builders:
							builder.download_and_prepare(
							    download_mode=DownloadMode.REUSE_CACHE_IF_EXISTS
							    if not self._force_redownload
							    else DownloadMode.FORCE_REDOWNLOAD						,	download_config=DownloadConfig(cache_dir=config.DOWNLOADED_DATASETS_PATH			)						,	verification_mode=VerificationMode.NO_CHECKS
							    if self._ignore_verifications
							    else VerificationMode.ALL_CHECKS						,	try_from_hf_gcs=lowerCamelCase__						,	)
							if self._save_infos:
									builder._save_infos()

					print("Apache beam run successful."			)

					# If save_infos=True, the dataset infos file is created next to the loaded module file.
					# Let's move it to the original directory of the dataset script, to allow the user to
					# upload them on S3 at the same time afterwards.
					if self._save_infos:
							_UpperCAmelCase		:							Optional[Any]             =   os.path.join(builder_cls.get_imported_module_dir()						,	config.DATASETDICT_INFOS_FILENAME			)

							_UpperCAmelCase		:							List[str]             =   Path(lowerCamelCase__			).name + ".py"

							_UpperCAmelCase		:							int             =   os.path.join(lowerCamelCase__						,	lowerCamelCase__			)
							if os.path.isfile(lowerCamelCase__			):
									_UpperCAmelCase		:							Any             =   os.path.dirname(lowerCamelCase__			)
							elif os.path.isfile(lowerCamelCase__			):
									_UpperCAmelCase		:							Tuple             =   path
							else:  # in case of a remote dataset
									print(F"""Dataset Infos file saved at {dataset_infos_path}"""			)
									exit(1			)

							# Move datasetinfo back to the user
							_UpperCAmelCase		:							Union[str, Any]             =   os.path.join(lowerCamelCase__						,	config.DATASETDICT_INFOS_FILENAME			)
							copyfile(lowerCamelCase__						,	lowerCamelCase__			)
							print(F"""Dataset Infos file saved at {user_dataset_infos_path}"""			)



