"""simple docstring"""




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        __SCREAMING_SNAKE_CASE     (   __lowerCamelCase							):







				@staticmethod
				def   lowercase_		(    __UpperCAmelCase    :ArgumentParser  )      ->					Optional[Any]:




									"""simple docstring"""



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

									# new system: git-based repo system
									lowerCamelCase__		:   Any  				=					parser.add_parser(
									    '''repo'''      ,help='''Deprecated: use `huggingface-cli` instead. Commands to interact with your huggingface.co repos.'''      ,)
									lowerCamelCase__		:   int  				=					repo_parser.add_subparsers(
									    help='''Deprecated: use `huggingface-cli` instead. huggingface.co repos related commands'''  )
									lowerCamelCase__		:   str  				=					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 __UpperCAmelCase  : RepoCreateCommand(lowerCamelCase_  )  )





class        __SCREAMING_SNAKE_CASE     :
				UpperCAmelCase	=      '''\u001b[1m'''
				UpperCAmelCase	=      '''\u001b[31m'''
				UpperCAmelCase	=      '''\u001b[90m'''
				UpperCAmelCase	=      '''\u001b[0m'''







				@classmethod
				def   lowercase_		(    cls    :int      ,__UpperCAmelCase    :List[str]  )      ->					Any:




									"""simple docstring"""



									return F"""{cls._bold}{s}{cls._reset}"""







				@classmethod
				def   lowercase_		(    cls    :List[Any]      ,__UpperCAmelCase    :Optional[Any]  )      ->					Tuple:




									"""simple docstring"""



									return F"""{cls._bold}{cls._red}{s}{cls._reset}"""







				@classmethod
				def   lowercase_		(    cls    :List[str]      ,__UpperCAmelCase    :List[str]  )      ->					Any:




									"""simple docstring"""



									return F"""{cls._gray}{s}{cls._reset}"""





def 				__a       (			_lowercase							, _lowercase						):







					"""simple docstring"""





					lowerCamelCase__		:   Optional[Any]  				=					[max(len(str(__UpperCAmelCase						)						) for x in col						) for col in zip(*__UpperCAmelCase							, __UpperCAmelCase						)]
					lowerCamelCase__		:   Optional[Any]  				=					('{{:{}}} ' * len(__UpperCAmelCase						)).format(*__UpperCAmelCase						)
					lowerCamelCase__		:   List[Any]  				=					[]
					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        __SCREAMING_SNAKE_CASE     :







				def __init__(    self    :str      ,__UpperCAmelCase    :List[str]  )      ->					Optional[Any]:




									"""simple docstring"""



									lowerCamelCase__		:   List[Any]  				=					args





class        __SCREAMING_SNAKE_CASE     (   __lowerCamelCase							):







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




									"""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        __SCREAMING_SNAKE_CASE     (   __lowerCamelCase							):







				def   lowercase_		(    self    :Optional[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.'''  )  )
									lowerCamelCase__		:   Optional[Any]  				=					HfFolder.get_token()
									if token is None:
														print('''Not logged in'''  )
														exit()
									try:
														lowerCamelCase__		:   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        __SCREAMING_SNAKE_CASE     (   __lowerCamelCase							):







				def   lowercase_		(    self    :Tuple  )      ->					Dict:




									"""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        __SCREAMING_SNAKE_CASE     (   __lowerCamelCase							):







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




									"""simple docstring"""



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

									lowerCamelCase__		:   List[str]  				=					whoami(lowerCamelCase_  )
									lowerCamelCase__		:   Any  				=					self.args.organization if self.args.organization is not None else user
									lowerCamelCase__		:   Tuple  				=					F"""{namespace}/{self.args.name}"""
									print(F"""You are about to create {ANSI.bold(lowerCamelCase_  )}"""  )

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







"""simple docstring"""







from ...configuration_utils import PretrainedConfig
from ...utils import logging


SCREAMING_SNAKE_CASE						=    logging.get_logger(__name__)

SCREAMING_SNAKE_CASE						=    {
    'facebook/regnet-y-040': 'https://huggingface.co/facebook/regnet-y-040/blob/main/config.json',
}



class 			_lowerCamelCase      (__lowerCamelCase  ):
				_snake_case  =	"regnet"
				_snake_case  =	["x", "y"]







				def __init__(			self     :							Any      ,       lowerCamelCase_     :							Optional[Any]=3      ,       lowerCamelCase_     :							List[str]=3_2      ,       lowerCamelCase_     :							str=[1_2_8, 1_9_2, 5_1_2, 1_0_8_8]      ,       lowerCamelCase_     :							int=[2, 6, 1_2, 2]      ,       lowerCamelCase_     :							Union[str, Any]=6_4      ,       lowerCamelCase_     :							int="y"      ,       lowerCamelCase_     :							Optional[Any]="relu"      ,       **lowerCamelCase_     :							Optional[Any]      ,       ):

					"""simple docstring"""






					super().__init__(**lowerCamelCase_    )
					if layer_type not in self.layer_types:
						raise ValueError(F'''layer_type={layer_type} is not one of {','.join(self.layer_types    )}'''    )
					_lowercase			:     str      					=				num_channels
					_lowercase			:     Optional[Any]      					=				embedding_size
					_lowercase			:     Union[str, Any]      					=				hidden_sizes
					_lowercase			:     Optional[int]      					=				depths
					_lowercase			:     Optional[int]      					=				groups_width
					_lowercase			:     Tuple      					=				layer_type
					_lowercase			:     Union[str, Any]      					=				hidden_act
					# always downsample in the first stage
					_lowercase			:     Optional[int]      					=				True



