code: 
  import collections
  import inspect
  import unittest
  
  from transformers import DinatConfig
  from transformers.testing_utils import require_natten, require_torch, require_vision, slow, torch_device
  from transformers.utils import cached_property, is_torch_available, is_vision_available
  
  from ...test_backbone_common import BackboneTesterMixin
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
  from ...test_pipeline_mixin import PipelineTesterMixin
  
  
  if is_torch_available():
  							import torch
  							from torch import nn
  
  							from transformers import DinatBackbone, DinatForImageClassification, DinatModel
  							from transformers.models.dinat.modeling_dinat import DINAT_PRETRAINED_MODEL_ARCHIVE_LIST
  
  if is_vision_available():
  							from PIL import Image
  
  							from transformers import AutoImageProcessor
  
  
  
  
  
  class 						lowerCamelCase			:
  
  
  
  
  
  
  
  	def __init__(    self			:List[Any]      ,    lowercase			:int      ,    lowercase			:int=1_3      ,    lowercase			:Tuple=6_4      ,    lowercase			:Tuple=4      ,    lowercase			:str=3      ,    lowercase			:List[Any]=1_6      ,    lowercase			:int=[1, 2, 1]      ,    lowercase			:Dict=[2, 4, 8]      ,    lowercase			:Optional[Any]=3      ,    lowercase			:Any=[[3], [1, 2], [1]]      ,    lowercase			:Optional[Any]=2.0      ,    lowercase			:Any=True      ,    lowercase			:Tuple=0.0      ,    lowercase			:List[str]=0.0      ,    lowercase			:Union[str, Any]=0.1      ,    lowercase			:List[str]="gelu"      ,    lowercase			:int=True      ,    lowercase			:str=0.02      ,    lowercase			:List[Any]=1e-5      ,    lowercase			:List[str]=True      ,    lowercase			:Optional[Any]=None      ,    lowercase			:List[str]=True      ,    lowercase			:Optional[Any]=1_0      ,    lowercase			:List[str]=["stage1", "stage2"]      ,    lowercase			:str=[1, 2]      ,    )		->			str:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   parent
  				SCREAMING_SNAKE_CASE    	=   batch_size
  				SCREAMING_SNAKE_CASE    	=   image_size
  				SCREAMING_SNAKE_CASE    	=   patch_size
  				SCREAMING_SNAKE_CASE    	=   num_channels
  				SCREAMING_SNAKE_CASE    	=   embed_dim
  				SCREAMING_SNAKE_CASE    	=   depths
  				SCREAMING_SNAKE_CASE    	=   num_heads
  				SCREAMING_SNAKE_CASE    	=   kernel_size
  				SCREAMING_SNAKE_CASE    	=   dilations
  				SCREAMING_SNAKE_CASE    	=   mlp_ratio
  				SCREAMING_SNAKE_CASE    	=   qkv_bias
  				SCREAMING_SNAKE_CASE    	=   hidden_dropout_prob
  				SCREAMING_SNAKE_CASE    	=   attention_probs_dropout_prob
  				SCREAMING_SNAKE_CASE    	=   drop_path_rate
  				SCREAMING_SNAKE_CASE    	=   hidden_act
  				SCREAMING_SNAKE_CASE    	=   patch_norm
  				SCREAMING_SNAKE_CASE    	=   layer_norm_eps
  				SCREAMING_SNAKE_CASE    	=   initializer_range
  				SCREAMING_SNAKE_CASE    	=   is_training
  				SCREAMING_SNAKE_CASE    	=   scope
  				SCREAMING_SNAKE_CASE    	=   use_labels
  				SCREAMING_SNAKE_CASE    	=   num_labels
  				SCREAMING_SNAKE_CASE    	=   out_features
  				SCREAMING_SNAKE_CASE    	=   out_indices
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:List[str] )		->			Dict:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size] )
  
  				SCREAMING_SNAKE_CASE    	=   None
  				if self.use_labels:
  							SCREAMING_SNAKE_CASE    	=   ids_tensor([self.batch_size]      ,    self.num_labels )
  
  				SCREAMING_SNAKE_CASE    	=   self.get_config()
  
  				return config, pixel_values, labels
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:Union[str, Any] )		->			List[str]:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				return DinatConfig(
  				    num_labels=self.num_labels      ,    image_size=self.image_size      ,    patch_size=self.patch_size      ,    num_channels=self.num_channels      ,    embed_dim=self.embed_dim      ,    depths=self.depths      ,    num_heads=self.num_heads      ,    kernel_size=self.kernel_size      ,    dilations=self.dilations      ,    mlp_ratio=self.mlp_ratio      ,    qkv_bias=self.qkv_bias      ,    hidden_dropout_prob=self.hidden_dropout_prob      ,    attention_probs_dropout_prob=self.attention_probs_dropout_prob      ,    drop_path_rate=self.drop_path_rate      ,    hidden_act=self.hidden_act      ,    patch_norm=self.patch_norm      ,    layer_norm_eps=self.layer_norm_eps      ,    initializer_range=self.initializer_range      ,    out_features=self.out_features      ,    out_indices=self.out_indices      ,    )
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:int      ,    lowercase			:Union[str, Any]      ,    lowercase			:str      ,    lowercase			:Any )		->			Optional[int]:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   DinatModel(config=lowercase )
  				model.to(lowercase )
  				model.eval()
  				SCREAMING_SNAKE_CASE    	=   model(lowercase )
  
  				SCREAMING_SNAKE_CASE    	=   SCREAMING_SNAKE_CASE    	=   (config.image_size // config.patch_size) // (2 ** (len(config.depths ) - 1))
  				SCREAMING_SNAKE_CASE    	=   int(config.embed_dim * 2 ** (len(config.depths ) - 1) )
  
  				self.parent.assertEqual(
  				    result.last_hidden_state.shape      ,    (self.batch_size, expected_height, expected_width, expected_dim) )
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:int      ,    lowercase			:Any      ,    lowercase			:List[str]      ,    lowercase			:Optional[int] )		->			List[str]:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   DinatForImageClassification(lowercase )
  				model.to(lowercase )
  				model.eval()
  				SCREAMING_SNAKE_CASE    	=   model(lowercase      ,    labels=lowercase )
  				self.parent.assertEqual(result.logits.shape      ,    (self.batch_size, self.num_labels) )
  
  				# test greyscale images
  				SCREAMING_SNAKE_CASE    	=   1
  				SCREAMING_SNAKE_CASE    	=   DinatForImageClassification(lowercase )
  				model.to(lowercase )
  				model.eval()
  
  				SCREAMING_SNAKE_CASE    	=   floats_tensor([self.batch_size, 1, self.image_size, self.image_size] )
  				SCREAMING_SNAKE_CASE    	=   model(lowercase )
  				self.parent.assertEqual(result.logits.shape      ,    (self.batch_size, self.num_labels) )
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:Dict      ,    lowercase			:Tuple      ,    lowercase			:List[Any]      ,    lowercase			:Optional[Any] )		->			Optional[int]:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   DinatBackbone(config=lowercase )
  				model.to(lowercase )
  				model.eval()
  				SCREAMING_SNAKE_CASE    	=   model(lowercase )
  
  				# verify hidden states
  				self.parent.assertEqual(len(result.feature_maps )      ,    len(config.out_features ) )
  				self.parent.assertListEqual(list(result.feature_maps[0].shape )      ,    [self.batch_size, model.channels[0], 1_6, 1_6] )
  
  				# verify channels
  				self.parent.assertEqual(len(model.channels )      ,    len(config.out_features ) )
  
  				# verify backbone works with out_features=None
  				SCREAMING_SNAKE_CASE    	=   None
  				SCREAMING_SNAKE_CASE    	=   DinatBackbone(config=lowercase )
  				model.to(lowercase )
  				model.eval()
  				SCREAMING_SNAKE_CASE    	=   model(lowercase )
  
  				# verify feature maps
  				self.parent.assertEqual(len(result.feature_maps )      ,    1 )
  				self.parent.assertListEqual(list(result.feature_maps[0].shape )      ,    [self.batch_size, model.channels[-1], 4, 4] )
  
  				# verify channels
  				self.parent.assertEqual(len(model.channels )      ,    1 )
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:Tuple )		->			int:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   self.prepare_config_and_inputs()
  				SCREAMING_SNAKE_CASE	,       SCREAMING_SNAKE_CASE	,       SCREAMING_SNAKE_CASE    	=   config_and_inputs
  				SCREAMING_SNAKE_CASE    	=   {'''pixel_values''': pixel_values}
  				return config, inputs_dict
  
  
  
  
  
  @require_natten
  @require_torch
  class 						lowerCamelCase			(					__lowerCamelCase   ,		__lowerCamelCase   ,		unittest.TestCase				):
  	UpperCamelCase_     :				Tuple								=  (
  	    (
  	        DinatModel,
  	        DinatForImageClassification,
  	        DinatBackbone,
  	    )
  	    if is_torch_available()
  	    else ()
  	)
  	UpperCamelCase_     :				List[Any]								=  (
  	    {'feature-extraction': DinatModel, 'image-classification': DinatForImageClassification}
  	    if is_torch_available()
  	    else {}
  	)
  	UpperCamelCase_     :				Dict								=  False
  
  	UpperCamelCase_     :				Union[str, Any]								=  False
  	UpperCamelCase_     :				List[str]								=  False
  	UpperCamelCase_     :				List[str]								=  False
  	UpperCamelCase_     :				str								=  False
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:List[Any] )		->			Tuple:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   DinatModelTester(self )
  				SCREAMING_SNAKE_CASE    	=   ConfigTester(self      ,    config_class=lowercase      ,    embed_dim=3_7 )
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:Tuple )		->			Union[str, Any]:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				self.create_and_test_config_common_properties()
  				self.config_tester.create_and_test_config_to_json_string()
  				self.config_tester.create_and_test_config_to_json_file()
  				self.config_tester.create_and_test_config_from_and_save_pretrained()
  				self.config_tester.create_and_test_config_with_num_labels()
  				self.config_tester.check_config_can_be_init_without_params()
  				self.config_tester.check_config_arguments_init()
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:Tuple )		->			Optional[Any]:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				return
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:Optional[Any] )		->			int:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   self.model_tester.prepare_config_and_inputs()
  				self.model_tester.create_and_check_model(*lowercase )
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:Any )		->			Union[str, Any]:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   self.model_tester.prepare_config_and_inputs()
  				self.model_tester.create_and_check_for_image_classification(*lowercase )
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:str )		->			List[str]:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   self.model_tester.prepare_config_and_inputs()
  				self.model_tester.create_and_check_backbone(*lowercase )
  
  
  
  
  
  
  
  	@unittest.skip(reason='''Dinat does not use inputs_embeds''' )
  	def    snake_case__    (    self			:int )		->			Dict:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				pass
  
  
  
  
  
  
  
  	@unittest.skip(reason='''Dinat does not use feedforward chunking''' )
  	def    snake_case__    (    self			:Dict )		->			List[Any]:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				pass
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:List[Any] )		->			int:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE	,       SCREAMING_SNAKE_CASE    	=   self.model_tester.prepare_config_and_inputs_for_common()
  
  				for model_class in self.all_model_classes:
  							SCREAMING_SNAKE_CASE    	=   model_class(lowercase )
  							self.assertIsInstance(model.get_input_embeddings()      ,    (nn.Module) )
  							SCREAMING_SNAKE_CASE    	=   model.get_output_embeddings()
  							self.assertTrue(x is None or isinstance(lowercase      ,    nn.Linear ) )
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:int )		->			Any:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE	,       SCREAMING_SNAKE_CASE    	=   self.model_tester.prepare_config_and_inputs_for_common()
  
  				for model_class in self.all_model_classes:
  							SCREAMING_SNAKE_CASE    	=   model_class(lowercase )
  							SCREAMING_SNAKE_CASE    	=   inspect.signature(model.forward )
  							# signature.parameters is an OrderedDict => so arg_names order is deterministic
  							SCREAMING_SNAKE_CASE    	=   [*signature.parameters.keys()]
  
  							SCREAMING_SNAKE_CASE    	=   ['''pixel_values''']
  							self.assertListEqual(arg_names[:1]      ,    lowercase )
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:int )		->			int:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				self.skipTest('''Dinat\'s attention operation is handled entirely by NATTEN.''' )
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:List[Any]      ,    lowercase			:Optional[int]      ,    lowercase			:int      ,    lowercase			:Dict      ,    lowercase			:Dict )		->			str:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   model_class(lowercase )
  				model.to(lowercase )
  				model.eval()
  
  				with torch.no_grad():
  							SCREAMING_SNAKE_CASE    	=   model(**self._prepare_for_class(lowercase      ,    lowercase ) )
  
  				SCREAMING_SNAKE_CASE    	=   outputs.hidden_states
  
  				SCREAMING_SNAKE_CASE    	=   getattr(
  				    self.model_tester      ,    '''expected_num_hidden_layers'''      ,    len(self.model_tester.depths ) + 1 )
  				self.assertEqual(len(lowercase )      ,    lowercase )
  
  				# Dinat has a different seq_length
  				SCREAMING_SNAKE_CASE    	=   (
  				    config.patch_size
  				    if isinstance(config.patch_size      ,    collections.abc.Iterable )
  				    else (config.patch_size, config.patch_size)
  				)
  
  				SCREAMING_SNAKE_CASE    	=   image_size[0] // patch_size[0]
  				SCREAMING_SNAKE_CASE    	=   image_size[1] // patch_size[1]
  
  				self.assertListEqual(
  				    list(hidden_states[0].shape[-3:] )      ,    [height, width, self.model_tester.embed_dim]      ,    )
  
  				if model_class.__name__ != "DinatBackbone":
  							SCREAMING_SNAKE_CASE    	=   outputs.reshaped_hidden_states
  							self.assertEqual(len(lowercase )      ,    lowercase )
  
  							SCREAMING_SNAKE_CASE	,       SCREAMING_SNAKE_CASE	,       SCREAMING_SNAKE_CASE	,       SCREAMING_SNAKE_CASE    	=   reshaped_hidden_states[0].shape
  							SCREAMING_SNAKE_CASE    	=   (
  							    reshaped_hidden_states[0].view(lowercase      ,    lowercase      ,    lowercase      ,    lowercase ).permute(0      ,    2      ,    3      ,    1 )
  							)
  							self.assertListEqual(
  							    list(reshaped_hidden_states.shape[-3:] )      ,    [height, width, self.model_tester.embed_dim]      ,    )
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:int )		->			Dict:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE	,       SCREAMING_SNAKE_CASE    	=   self.model_tester.prepare_config_and_inputs_for_common()
  
  				SCREAMING_SNAKE_CASE    	=   (
  				    self.model_tester.image_size
  				    if isinstance(self.model_tester.image_size      ,    collections.abc.Iterable )
  				    else (self.model_tester.image_size, self.model_tester.image_size)
  				)
  
  				for model_class in self.all_model_classes:
  							SCREAMING_SNAKE_CASE    	=   True
  							self.check_hidden_states_output(lowercase      ,    lowercase      ,    lowercase      ,    lowercase )
  
  							# check that output_hidden_states also work using config
  							del inputs_dict["output_hidden_states"]
  							SCREAMING_SNAKE_CASE    	=   True
  
  							self.check_hidden_states_output(lowercase      ,    lowercase      ,    lowercase      ,    lowercase )
  
  
  
  
  
  
  
  	@slow
  	def    snake_case__    (    self			:Dict )		->			Tuple:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				for model_name in DINAT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
  							SCREAMING_SNAKE_CASE    	=   DinatModel.from_pretrained(lowercase )
  							self.assertIsNotNone(lowercase )
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:List[Any] )		->			Optional[Any]:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE	,       SCREAMING_SNAKE_CASE    	=   self.model_tester.prepare_config_and_inputs_for_common()
  
  				SCREAMING_SNAKE_CASE    	=   _config_zero_init(lowercase )
  				for model_class in self.all_model_classes:
  							SCREAMING_SNAKE_CASE    	=   model_class(config=lowercase )
  							for name, param in model.named_parameters():
  										if "embeddings" not in name and param.requires_grad:
  													self.assertIn(
  													    ((param.data.mean() * 1e9).round() / 1e9).item()      ,    [0.0, 1.0]      ,    msg=f"""Parameter {name} of model {model_class} seems not properly initialized"""      ,    )
  
  
  
  
  
  @require_natten
  @require_vision
  @require_torch
  class 						lowerCamelCase			(					unittest.TestCase				):
  
  
  
  
  
  
  
  	@cached_property
  	def    snake_case__    (    self			:Optional[Any] )		->			Optional[int]:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				return AutoImageProcessor.from_pretrained('''shi-labs/dinat-mini-in1k-224''' ) if is_vision_available() else None
  
  
  
  
  
  
  
  	@slow
  	def    snake_case__    (    self			:Any )		->			Any:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   DinatForImageClassification.from_pretrained('''shi-labs/dinat-mini-in1k-224''' ).to(lowercase )
  				SCREAMING_SNAKE_CASE    	=   self.default_image_processor
  
  				SCREAMING_SNAKE_CASE    	=   Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png''' )
  				SCREAMING_SNAKE_CASE    	=   image_processor(images=lowercase      ,    return_tensors='''pt''' ).to(lowercase )
  
  				# forward pass
  				with torch.no_grad():
  							SCREAMING_SNAKE_CASE    	=   model(**lowercase )
  
  				# verify the logits
  				SCREAMING_SNAKE_CASE    	=   torch.Size((1, 1_0_0_0) )
  				self.assertEqual(outputs.logits.shape      ,    lowercase )
  				SCREAMING_SNAKE_CASE    	=   torch.tensor([-0.15_45, -0.76_67, 0.46_42] ).to(lowercase )
  				self.assertTrue(torch.allclose(outputs.logits[0, :3]      ,    lowercase      ,    atol=1e-4 ) )
  
  
  
  
  
  @require_torch
  @require_natten
  class 						lowerCamelCase			(					unittest.TestCase   ,		__lowerCamelCase				):
  	UpperCamelCase_     :				List[Any]								=  (DinatBackbone,) if is_torch_available() else ()
  	UpperCamelCase_     :				str								=  DinatConfig
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:List[str] )		->			Tuple:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   DinatModelTester(self )
style_context: 
  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 						lowerCamelCase			(					__lowerCamelCase				):
  
  
  
  
  
  
  
  	@staticmethod
  	def    snake_case__    (    lowercase			:ArgumentParser )		->			Union[str, Any]:
  
  
  
  
  
  
  
  				"""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 lowercase : LoginCommand(lowercase ) )
  				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 lowercase : WhoamiCommand(lowercase ) )
  				SCREAMING_SNAKE_CASE    	=   parser.add_parser('''logout'''      ,    help='''Log out''' )
  				logout_parser.set_defaults(func=lambda lowercase : LogoutCommand(lowercase ) )
  
  				# 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=lowercase      ,    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=lowercase      ,    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 lowercase : RepoCreateCommand(lowercase ) )
  
  
  
  
  
  class 						lowerCamelCase			:
  	UpperCamelCase_     :				List[str]								=  '\u001b[1m'
  	UpperCamelCase_     :				Union[str, Any]								=  '\u001b[31m'
  	UpperCamelCase_     :				Any								=  '\u001b[90m'
  	UpperCamelCase_     :				List[str]								=  '\u001b[0m'
  
  
  
  
  
  
  
  	@classmethod
  	def    snake_case__    (    cls			:List[Any]      ,    lowercase			:Any )		->			List[str]:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				return f"""{cls._bold}{s}{cls._reset}"""
  
  
  
  
  
  
  
  	@classmethod
  	def    snake_case__    (    cls			:Optional[Any]      ,    lowercase			:str )		->			Tuple:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				return f"""{cls._bold}{cls._red}{s}{cls._reset}"""
  
  
  
  
  
  
  
  	@classmethod
  	def    snake_case__    (    cls			:List[str]      ,    lowercase			:Any )		->			List[Any]:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				return f"""{cls._gray}{s}{cls._reset}"""
  
  
  
  def       a			(   a		,	a  )    ->str:
  
  
  
  
  			'''simple docstring'''
  
  
  			SCREAMING_SNAKE_CASE    	=   [max(len(str(a  )  ) for x in col  ) for col in zip(*a		,	a  )]
  			SCREAMING_SNAKE_CASE    	=   ('''{{:{}}} ''' * len(a  )).format(*a  )
  			SCREAMING_SNAKE_CASE    	=   []
  			lines.append(row_format.format(*a  )  )
  			lines.append(row_format.format(*['''-''' * w for w in col_widths]  )  )
  			for row in rows:
  						lines.append(row_format.format(*a  )  )
  			return "\n".join(a  )
  
  
  
  
  
  class 						lowerCamelCase			:
  
  
  
  
  
  
  
  	def __init__(    self			:List[str]      ,    lowercase			:Optional[Any] )		->			Union[str, Any]:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   args
  
  
  
  
  
  class 						lowerCamelCase			(					__lowerCamelCase				):
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:List[str] )		->			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 						lowerCamelCase			(					__lowerCamelCase				):
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:List[Any] )		->			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(lowercase )
  							print(lowercase )
  							if orgs:
  										print(ANSI.bold('''orgs: ''' )      ,    ''','''.join(lowercase ) )
  				except HTTPError as e:
  							print(lowercase )
  							print(ANSI.red(e.response.text ) )
  							exit(1 )
  
  
  
  
  
  class 						lowerCamelCase			(					__lowerCamelCase				):
  
  
  
  
  
  
  
  	def    snake_case__    (    self			: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 						lowerCamelCase			(					__lowerCamelCase				):
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:int )		->			Optional[Any]:
  
  
  
  
  
  
  
  				"""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(lowercase )
  				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(lowercase )}""" )
  
  				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(lowercase      ,    name=self.args.name      ,    organization=self.args.organization )
  				except HTTPError as e:
  							print(lowercase )
  							print(ANSI.red(e.response.text ) )
  							exit(1 )
  				print('''\nYour repo now lives at:''' )
  				print(f"""  {ANSI.bold(lowercase )}""" )
  				print('''\nYou can clone it locally with the command below, and commit/push as usual.''' )
  				print(f"""\n  git clone {url}""" )
  				print('''''' )