code: 
  
  
  import subprocess
  from argparse import ArgumentParser
  from typing import List, Union
  
  from huggingface_hub.hf_api import HfFolder, create_repo, whoami
  from requests.exceptions import HTTPError
  
  from . import BaseTransformersCLICommand
  
  class 						snake_case			(       lowerCAmelCase__	):
  			'''simple docstring'''
  
  			@staticmethod
  			def _lowercase (	lowerCAmelCase_     :     ArgumentParser					)					->					int:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       parser.add_parser('''login'''							,							help='''Log in using the same credentials as on huggingface.co'''					)
  								login_parser.set_defaults(func=lambda lowerCAmelCase_					: LoginCommand(lowerCAmelCase_					)					)
  								SCREAMING_SNAKE_CASE_	      =       parser.add_parser('''whoami'''							,							help='''Find out which huggingface.co account you are logged in as.'''					)
  								whoami_parser.set_defaults(func=lambda lowerCAmelCase_					: WhoamiCommand(lowerCAmelCase_					)					)
  								SCREAMING_SNAKE_CASE_	      =       parser.add_parser('''logout'''							,							help='''Log out'''					)
  								logout_parser.set_defaults(func=lambda lowerCAmelCase_					: LogoutCommand(lowerCAmelCase_					)					)
  
  								# new system: git-based repo system
  								SCREAMING_SNAKE_CASE_	      =       parser.add_parser(
  								    '''repo'''							,							help='''Deprecated: use `huggingface-cli` instead. Commands to interact with your huggingface.co repos.'''							,							)
  								SCREAMING_SNAKE_CASE_	      =       repo_parser.add_subparsers(
  								    help='''Deprecated: use `huggingface-cli` instead. huggingface.co repos related commands'''					)
  								SCREAMING_SNAKE_CASE_	      =       repo_subparsers.add_parser(
  								    '''create'''							,							help='''Deprecated: use `huggingface-cli` instead. Create a new repo on huggingface.co'''					)
  								repo_create_parser.add_argument(
  								    '''name'''							,							type=lowerCAmelCase_							,							help='''Name for your model\'s repo. Will be namespaced under your username to build the model id.'''							,							)
  								repo_create_parser.add_argument('''--organization'''							,							type=lowerCAmelCase_							,							help='''Optional: organization namespace.'''					)
  								repo_create_parser.add_argument('''-y'''							,							'''--yes'''							,							action='''store_true'''							,							help='''Optional: answer Yes to the prompt'''					)
  								repo_create_parser.set_defaults(func=lambda lowerCAmelCase_					: RepoCreateCommand(lowerCAmelCase_					)					)
  
  class 						snake_case			:
  			'''simple docstring'''
  
  			UpperCAmelCase       :       List[str]       = """\u001b[1m"""
  			UpperCAmelCase       :       Union[str, Any]       = """\u001b[31m"""
  			UpperCAmelCase       :       Any       = """\u001b[90m"""
  			UpperCAmelCase       :       List[str]       = """\u001b[0m"""
  
  			@classmethod
  			def _lowercase (	cls     :     Optional[int]							,							lowerCAmelCase_     :     Tuple					)					->					Tuple:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								return F'''{cls._bold}{s}{cls._reset}'''
  
  			@classmethod
  			def _lowercase (	cls     :     Union[str, Any]							,							lowerCAmelCase_     :     Tuple					)					->					Optional[Any]:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								return F'''{cls._bold}{cls._red}{s}{cls._reset}'''
  
  
  
  
  			@classmethod
  			def _lowercase (	cls     :     int							,							lowerCAmelCase_     :     List[str]					)					->					Union[str, Any]:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								return F'''{cls._gray}{s}{cls._reset}'''
  
  
  
  
  
  
  
  def 							UpperCAmelCase				(     UpperCAmelCase				,UpperCAmelCase      )->		str:
  
  
  
  
  
  
  
  					'''simple docstring'''
  
  
  
  					SCREAMING_SNAKE_CASE_	      =       [max(len(str(UpperCAmelCase      )      ) for x in col      ) for col in zip(*UpperCAmelCase				,UpperCAmelCase      )]
  					SCREAMING_SNAKE_CASE_	      =       ('''{{:{}}} ''' * len(UpperCAmelCase      )).format(*UpperCAmelCase      )
  					SCREAMING_SNAKE_CASE_	      =       []
  					lines.append(row_format.format(*UpperCAmelCase      )      )
  					lines.append(row_format.format(*['''-''' * w for w in col_widths]      )      )
  					for row in rows:
  										lines.append(row_format.format(*UpperCAmelCase      )      )
  					return "\n".join(UpperCAmelCase      )
  
  class 						snake_case			:
  			'''simple docstring'''
  
  			def __init__(	self     :     int							,							lowerCAmelCase_     :     List[str]					)					->					Tuple:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       args
  
  class 						snake_case			(       lowerCAmelCase__	):
  			'''simple docstring'''
  
  			def _lowercase (	self     :     Dict					)					->					int:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								print(
  								    ANSI.red(
  								        '''ERROR! `huggingface-cli login` uses an outdated login mechanism '''
  								        '''that is not compatible with the Hugging Face Hub backend anymore. '''
  								        '''Please use `huggingface-cli login instead.'''					)					)
  
  class 						snake_case			(       lowerCAmelCase__	):
  			'''simple docstring'''
  
  			def _lowercase (	self     :     List[Any]					)					->					Optional[Any]:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								print(
  								    ANSI.red(
  								        '''WARNING! `transformers-cli whoami` is deprecated and will be removed in v5. Please use '''
  								        '''`huggingface-cli whoami` instead.'''					)					)
  								SCREAMING_SNAKE_CASE_	      =       HfFolder.get_token()
  								if token is None:
  													print('''Not logged in'''					)
  													exit()
  								try:
  													SCREAMING_SNAKE_CASE_      ,SCREAMING_SNAKE_CASE_	      =       whoami(lowerCAmelCase_					)
  													print(lowerCAmelCase_					)
  													if orgs:
  																		print(ANSI.bold('''orgs: '''					)							,							''','''.join(lowerCAmelCase_					)					)
  								except HTTPError as e:
  													print(lowerCAmelCase_					)
  													print(ANSI.red(e.response.text					)					)
  													exit(1					)
  
  class 						snake_case			(       lowerCAmelCase__	):
  			'''simple docstring'''
  
  			def _lowercase (	self     :     List[str]					)					->					Union[str, Any]:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								print(
  								    ANSI.red(
  								        '''ERROR! `transformers-cli logout` uses an outdated logout mechanism '''
  								        '''that is not compatible with the Hugging Face Hub backend anymore. '''
  								        '''Please use `huggingface-cli logout instead.'''					)					)
  
  class 						snake_case			(       lowerCAmelCase__	):
  			'''simple docstring'''
  
  			def _lowercase (	self     :     Union[str, Any]					)					->					Optional[int]:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								print(
  								    ANSI.red(
  								        '''WARNING! Managing repositories through transformers-cli is deprecated. '''
  								        '''Please use `huggingface-cli` instead.'''					)					)
  								SCREAMING_SNAKE_CASE_	      =       HfFolder.get_token()
  								if token is None:
  													print('''Not logged in'''					)
  													exit(1					)
  								try:
  													SCREAMING_SNAKE_CASE_	      =       subprocess.check_output(['''git''', '''--version''']					).decode('''utf-8'''					)
  													print(ANSI.gray(stdout.strip()					)					)
  								except FileNotFoundError:
  													print('''Looks like you do not have git installed, please install.'''					)
  
  								try:
  													SCREAMING_SNAKE_CASE_	      =       subprocess.check_output(['''git-lfs''', '''--version''']					).decode('''utf-8'''					)
  													print(ANSI.gray(stdout.strip()					)					)
  								except FileNotFoundError:
  													print(
  													    ANSI.red(
  													        '''Looks like you do not have git-lfs installed, please install.'''
  													        ''' You can install from https://git-lfs.github.com/.'''
  													        ''' Then run `git lfs install` (you only have to do this once).'''					)					)
  								print(''''''					)
  
  								SCREAMING_SNAKE_CASE_      ,SCREAMING_SNAKE_CASE_	      =       whoami(lowerCAmelCase_					)
  								SCREAMING_SNAKE_CASE_	      =       self.args.organization if self.args.organization is not None else user
  								SCREAMING_SNAKE_CASE_	      =       F'''{namespace}/{self.args.name}'''
  								print(F'''You are about to create {ANSI.bold(lowerCAmelCase_					)}'''					)
  
  								if not self.args.yes:
  													SCREAMING_SNAKE_CASE_	      =       input('''Proceed? [Y/n] '''					).lower()
  													if not (choice == "" or choice == "y" or choice == "yes"):
  																		print('''Abort'''					)
  																		exit()
  								try:
  													SCREAMING_SNAKE_CASE_	      =       create_repo(lowerCAmelCase_							,							name=self.args.name							,							organization=self.args.organization					)
  								except HTTPError as e:
  													print(lowerCAmelCase_					)
  													print(ANSI.red(e.response.text					)					)
  													exit(1					)
  								print('''\nYour repo now lives at:'''					)
  								print(F'''  {ANSI.bold(lowerCAmelCase_					)}'''					)
  								print('''\nYou can clone it locally with the command below, and commit/push as usual.'''					)
  								print(F'''\n  git clone {url}'''					)
  								print(''''''					)
  
  
  
style_context: 
  
  
  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 							UpperCAmelCase				(     UpperCAmelCase				,**UpperCAmelCase      )->		Tuple:
  
  
  
  
  
  
  
  					'''simple docstring'''
  
  
  
  					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				,**UpperCAmelCase				,)
  
  
  
  
  
  
  class 						snake_case			(       lowerCAmelCase__	):
  			'''simple docstring'''
  
  			@staticmethod
  			def _lowercase (	lowerCAmelCase_     :     ArgumentParser					)					->					List[str]:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       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     :     Any							,							lowerCAmelCase_     :     str							,							lowerCAmelCase_     :     str							,							lowerCAmelCase_     :     str							,							lowerCAmelCase_     :     str							,							lowerCAmelCase_     :     str							,							lowerCAmelCase_     :     bool							,							lowerCAmelCase_     :     bool							,							lowerCAmelCase_     :     bool							,							lowerCAmelCase_     :     bool							,							**lowerCAmelCase_     :     Any							,							)					->					Tuple:
  
  
  
  
  								"""simple docstring"""
  
  
  
  
  
  
  								SCREAMING_SNAKE_CASE_	      =       dataset
  								SCREAMING_SNAKE_CASE_	      =       name
  								SCREAMING_SNAKE_CASE_	      =       cache_dir
  								SCREAMING_SNAKE_CASE_	      =       beam_pipeline_options
  								SCREAMING_SNAKE_CASE_	      =       data_dir
  								SCREAMING_SNAKE_CASE_	      =       all_configs
  								SCREAMING_SNAKE_CASE_	      =       save_infos
  								SCREAMING_SNAKE_CASE_	      =       ignore_verifications
  								SCREAMING_SNAKE_CASE_	      =       force_redownload
  								SCREAMING_SNAKE_CASE_	      =       config_kwargs
  
  
  
  
  			def _lowercase (	self     :     List[str]					)					->					int:
  
  
  
  
  								"""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					)
  								SCREAMING_SNAKE_CASE_      ,SCREAMING_SNAKE_CASE_	      =       self._dataset, self._name
  								SCREAMING_SNAKE_CASE_	      =       dataset_module_factory(lowerCAmelCase_					)
  								SCREAMING_SNAKE_CASE_	      =       import_main_class(dataset_module.module_path					)
  								SCREAMING_SNAKE_CASE_	      =       []
  								if self._beam_pipeline_options:
  													SCREAMING_SNAKE_CASE_	      =       beam.options.pipeline_options.PipelineOptions(
  													    flags=[F'''--{opt.strip()}''' for opt in self._beam_pipeline_options.split(''','''					) if opt]					)
  								else:
  													SCREAMING_SNAKE_CASE_	      =       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:
  													SCREAMING_SNAKE_CASE_	      =       os.path.join(builder_cls.get_imported_module_dir()							,							config.DATASETDICT_INFOS_FILENAME					)
  
  													SCREAMING_SNAKE_CASE_	      =       Path(lowerCAmelCase_					).name + '''.py'''
  
  													SCREAMING_SNAKE_CASE_	      =       os.path.join(lowerCAmelCase_							,							lowerCAmelCase_					)
  													if os.path.isfile(lowerCAmelCase_					):
  																		SCREAMING_SNAKE_CASE_	      =       os.path.dirname(lowerCAmelCase_					)
  													elif os.path.isfile(lowerCAmelCase_					):
  																		SCREAMING_SNAKE_CASE_	      =       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
  													SCREAMING_SNAKE_CASE_	      =       os.path.join(lowerCAmelCase_							,							config.DATASETDICT_INFOS_FILENAME					)
  													copyfile(lowerCAmelCase_							,							lowerCAmelCase_					)
  													print(F'''Dataset Infos file saved at {user_dataset_infos_path}'''					)
  
  
  