




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__   ):
 @staticmethod
 def 	UpperCAmelCase__       (  snake_case__						)	->							int:
       '''simple docstring'''





       UpperCAmelCase    : Optional[Any]      =parser.add_parser('''login'''		,   help='''Log in using the same credentials as on huggingface.co'''						)
       login_parser.set_defaults(func=lambda snake_case__						: LoginCommand(lowerCAmelCase_						)						)
       UpperCAmelCase    : Optional[Any]      =parser.add_parser('''whoami'''		,   help='''Find out which huggingface.co account you are logged in as.'''						)
       whoami_parser.set_defaults(func=lambda snake_case__						: WhoamiCommand(lowerCAmelCase_						)						)
       UpperCAmelCase    : str      =parser.add_parser('''logout'''		,   help='''Log out'''						)
       logout_parser.set_defaults(func=lambda snake_case__						: LogoutCommand(lowerCAmelCase_						)						)

       # new system: git-based repo system
       UpperCAmelCase    : Tuple      =parser.add_parser(
           '''repo'''		,   help='''Deprecated: use `huggingface-cli` instead. Commands to interact with your huggingface.co repos.'''		,   )
       UpperCAmelCase    : Optional[Any]      =repo_parser.add_subparsers(
           help='''Deprecated: use `huggingface-cli` instead. huggingface.co repos related commands'''						)
       UpperCAmelCase    : Any      =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 snake_case__						: RepoCreateCommand(lowerCAmelCase_						)						)







class 			__snake_case   :
 __lowerCamelCase    :   List[str]     =      """\u001b[1m"""
 __lowerCamelCase    :   Union[str, Any]     =      """\u001b[31m"""
 __lowerCamelCase    :   Any     =      """\u001b[90m"""
 __lowerCamelCase    :   List[str]     =      """\u001b[0m"""
 @classmethod
 def 	UpperCAmelCase__       (  cls		,   snake_case__						)	->							Tuple:
       '''simple docstring'''





       return f'''{cls._bold}{s}{cls._reset}'''
 @classmethod
 def 	UpperCAmelCase__       (  cls		,   snake_case__						)	->							Optional[Any]:
       '''simple docstring'''





       return f'''{cls._bold}{cls._red}{s}{cls._reset}'''






 @classmethod
 def 	UpperCAmelCase__       (  cls		,   snake_case__						)	->							Union[str, Any]:
       '''simple docstring'''





       return f'''{cls._gray}{s}{cls._reset}'''





def   lowerCAmelCase_ (				__lowerCAmelCase		,					__lowerCAmelCase						)->  str:






      '''simple docstring'''





      UpperCAmelCase    : Optional[Any]      =[max(len(str(__lowerCAmelCase						)						) for x in col						) for col in zip(*__lowerCAmelCase		,					__lowerCAmelCase						)]
      UpperCAmelCase    : Optional[int]      =('''{{:{}}} ''' * len(__lowerCAmelCase						)).format(*__lowerCAmelCase						)
      UpperCAmelCase    : Optional[int]      =[]
      lines.append(row_format.format(*__lowerCAmelCase						)						)
      lines.append(row_format.format(*['''-''' * w for w in col_widths]						)						)
      for row in rows:
            lines.append(row_format.format(*__lowerCAmelCase						)						)
      return "\n".join(__lowerCAmelCase						)







class 			__snake_case   :
 def __init__(  self		,   snake_case__						)	->							Tuple:
       '''simple docstring'''





       UpperCAmelCase    : Optional[Any]      =args







class 			__snake_case   (     lowerCAmelCase__   ):
 def 	UpperCAmelCase__       (  self						)	->							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__   ):
 def 	UpperCAmelCase__       (  self						)	->							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.'''						)						)
       UpperCAmelCase    : Tuple      =HfFolder.get_token()
       if token is None:
             print('''Not logged in'''						)
             exit()
       try:
             UpperCAmelCase  ,						UpperCAmelCase    : List[str]      =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__   ):
 def 	UpperCAmelCase__       (  self						)	->							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__   ):
 def 	UpperCAmelCase__       (  self						)	->							Optional[int]:
       '''simple docstring'''





       print(
           ANSI.red(
               '''WARNING! Managing repositories through transformers-cli is deprecated. '''
               '''Please use `huggingface-cli` instead.'''						)						)
       UpperCAmelCase    : Optional[Any]      =HfFolder.get_token()
       if token is None:
             print('''Not logged in'''						)
             exit(1						)
       try:
             UpperCAmelCase    : Optional[int]      =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:
             UpperCAmelCase    : Union[str, Any]      =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(''''''						)

       UpperCAmelCase  ,						UpperCAmelCase    : List[Any]      =whoami(lowerCAmelCase_						)
       UpperCAmelCase    : Dict      =self.args.organization if self.args.organization is not None else user
       UpperCAmelCase    : Any      =f'''{namespace}/{self.args.name}'''
       print(f'''You are about to create {ANSI.bold(lowerCAmelCase_						)}'''						)

       if not self.args.yes:
             UpperCAmelCase    : str      =input('''Proceed? [Y/n] '''						).lower()
             if not (choice == "" or choice == "y" or choice == "yes"):
                   print('''Abort'''						)
                   exit()
       try:
             UpperCAmelCase    : str      =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(''''''						)

from collections import defaultdict





def   lowerCAmelCase_ (				__lowerCAmelCase = 5						)->  int:






      '''simple docstring'''





      UpperCAmelCase    : List[str]      =defaultdict(__lowerCAmelCase						)
      UpperCAmelCase    : Tuple      =0

      while True:
            UpperCAmelCase    : Any      =get_digits(__lowerCAmelCase						)
            freqs[digits].append(__lowerCAmelCase						)

            if len(freqs[digits]						) == max_base:
                  UpperCAmelCase    : Optional[int]      =freqs[digits][0] ** 3
                  return base

            num += 1





def   lowerCAmelCase_ (				__lowerCAmelCase						)->  str:






      '''simple docstring'''





      return "".join(sorted(str(num**3						)						)						)


if __name__ == "__main__":
     print(f'{solution() = }')
