






'''simple docstring'''







import collections
import inspect
import unittest

from transformers import SwinvaConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

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 SwinvaForImageClassification, SwinvaForMaskedImageModeling, SwinvaModel
			from transformers.models.swinva.modeling_swinva import SWINV2_PRETRAINED_MODEL_ARCHIVE_LIST

if is_vision_available():
			from PIL import Image

			from transformers import AutoImageProcessor

class _lowercase			:




							def __init__(							self:       int    ,							UpperCamelCase__:       str    ,							UpperCamelCase__:       Union[str, Any]=13    ,							UpperCamelCase__:       int=32    ,							UpperCamelCase__:       Optional[Any]=2    ,							UpperCamelCase__:       Tuple=3    ,							UpperCamelCase__:       List[Any]=16    ,							UpperCamelCase__:       List[str]=[1, 2, 1]    ,							UpperCamelCase__:       int=[2, 2, 4]    ,							UpperCamelCase__:       int=2    ,							UpperCamelCase__:       Optional[Any]=2.0    ,							UpperCamelCase__:       Optional[int]=True    ,							UpperCamelCase__:       Dict=0.0    ,							UpperCamelCase__:       Any=0.0    ,							UpperCamelCase__:       int=0.1    ,							UpperCamelCase__:       List[str]="gelu"    ,							UpperCamelCase__:       Optional[Any]=False    ,							UpperCamelCase__:       str=True    ,							UpperCamelCase__:       Dict=0.02    ,							UpperCamelCase__:       Any=1e-5    ,							UpperCamelCase__:       Optional[int]=True    ,							UpperCamelCase__:       str=None    ,							UpperCamelCase__:       str=True    ,							UpperCamelCase__:       int=10    ,							UpperCamelCase__:       str=8    ,							):
														lowerCamelCase__      :			str 						= parent
														lowerCamelCase__      :			Union[str, Any] 						= batch_size
														lowerCamelCase__      :			List[str] 						= image_size
														lowerCamelCase__      :			Optional[Any] 						= patch_size
														lowerCamelCase__      :			Tuple 						= num_channels
														lowerCamelCase__      :			Optional[int] 						= embed_dim
														lowerCamelCase__      :			Tuple 						= depths
														lowerCamelCase__      :			List[str] 						= num_heads
														lowerCamelCase__      :			List[Any] 						= window_size
														lowerCamelCase__      :			Any 						= mlp_ratio
														lowerCamelCase__      :			Optional[Any] 						= qkv_bias
														lowerCamelCase__      :			Any 						= hidden_dropout_prob
														lowerCamelCase__      :			Optional[int] 						= attention_probs_dropout_prob
														lowerCamelCase__      :			int 						= drop_path_rate
														lowerCamelCase__      :			Optional[Any] 						= hidden_act
														lowerCamelCase__      :			int 						= use_absolute_embeddings
														lowerCamelCase__      :			List[str] 						= patch_norm
														lowerCamelCase__      :			Optional[int] 						= layer_norm_eps
														lowerCamelCase__      :			List[str] 						= initializer_range
														lowerCamelCase__      :			Optional[Any] 						= is_training
														lowerCamelCase__      :			List[Any] 						= scope
														lowerCamelCase__      :			Dict 						= use_labels
														lowerCamelCase__      :			List[Any] 						= type_sequence_label_size
														lowerCamelCase__      :			Optional[Any] 						= encoder_stride




							def 	lowerCamelCase_       (							self:       int  ):
														lowerCamelCase__      :			Union[str, Any] 						= floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]  )

														lowerCamelCase__      :			Optional[Any] 						= None
														if self.use_labels:
																					lowerCamelCase__      :			Tuple 						= ids_tensor([self.batch_size]    ,							self.type_sequence_label_size  )

														lowerCamelCase__      :			int 						= self.get_config()

														return config, pixel_values, labels




							def 	lowerCamelCase_       (							self:       List[str]  ):
														return SwinvaConfig(
														    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    ,							window_size=self.window_size    ,							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    ,							use_absolute_embeddings=self.use_absolute_embeddings    ,							path_norm=self.patch_norm    ,							layer_norm_eps=self.layer_norm_eps    ,							initializer_range=self.initializer_range    ,							encoder_stride=self.encoder_stride    ,							)




							def 	lowerCamelCase_       (							self:       List[str]    ,							UpperCamelCase__:       Any    ,							UpperCamelCase__:       str    ,							UpperCamelCase__:       str  ):
														lowerCamelCase__      :			Optional[int] 						= SwinvaModel(config=UpperCamelCase__  )
														model.to(UpperCamelCase__  )
														model.eval()
														lowerCamelCase__      :			Optional[int] 						= model(UpperCamelCase__  )

														lowerCamelCase__      :			str 						= ((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths  ) - 1))
														lowerCamelCase__      :			Tuple 						= int(config.embed_dim * 2 ** (len(config.depths  ) - 1)  )

														self.parent.assertEqual(result.last_hidden_state.shape    ,							(self.batch_size, expected_seq_len, expected_dim)  )




							def 	lowerCamelCase_       (							self:       Union[str, Any]    ,							UpperCamelCase__:       Optional[Any]    ,							UpperCamelCase__:       Tuple    ,							UpperCamelCase__:       int  ):
														lowerCamelCase__      :			Any 						= SwinvaForMaskedImageModeling(config=UpperCamelCase__  )
														model.to(UpperCamelCase__  )
														model.eval()
														lowerCamelCase__      :			str 						= model(UpperCamelCase__  )
														self.parent.assertEqual(
														    result.logits.shape    ,							(self.batch_size, self.num_channels, self.image_size, self.image_size)  )

														# test greyscale images
														lowerCamelCase__      :			Any 						= 1
														lowerCamelCase__      :			Dict 						= SwinvaForMaskedImageModeling(UpperCamelCase__  )
														model.to(UpperCamelCase__  )
														model.eval()

														lowerCamelCase__      :			Optional[int] 						= floats_tensor([self.batch_size, 1, self.image_size, self.image_size]  )
														lowerCamelCase__      :			List[str] 						= model(UpperCamelCase__  )
														self.parent.assertEqual(result.logits.shape    ,							(self.batch_size, 1, self.image_size, self.image_size)  )




							def 	lowerCamelCase_       (							self:       Union[str, Any]    ,							UpperCamelCase__:       int    ,							UpperCamelCase__:       str    ,							UpperCamelCase__:       Any  ):
														lowerCamelCase__      :			str 						= self.type_sequence_label_size
														lowerCamelCase__      :			List[Any] 						= SwinvaForImageClassification(UpperCamelCase__  )
														model.to(UpperCamelCase__  )
														model.eval()
														lowerCamelCase__      :			Union[str, Any] 						= model(UpperCamelCase__    ,							labels=UpperCamelCase__  )
														self.parent.assertEqual(result.logits.shape    ,							(self.batch_size, self.type_sequence_label_size)  )




							def 	lowerCamelCase_       (							self:       int  ):
														lowerCamelCase__      :			Tuple 						= self.prepare_config_and_inputs()
														lowerCamelCase__      :			Optional[int] 						= config_and_inputs
														lowerCamelCase__      :			str 						= {'pixel_values': pixel_values}
														return config, inputs_dict



@require_torch
class _lowercase			(       _lowercase       ,   _lowercase       ,   unittest.TestCase	):
							a          = (
							    (SwinvaModel, SwinvaForImageClassification, SwinvaForMaskedImageModeling) if is_torch_available() else ()
							)
							a          = (
							    {"""feature-extraction""": SwinvaModel, """image-classification""": SwinvaForImageClassification}
							    if is_torch_available()
							    else {}
							)

							a          = False
							a          = False
							a          = False
							a          = False




							def 	lowerCamelCase_       (							self:       Tuple  ):
														lowerCamelCase__      :			Optional[Any] 						= SwinvaModelTester(self  )
														lowerCamelCase__      :			int 						= ConfigTester(self    ,							config_class=UpperCamelCase__    ,							embed_dim=37  )




							def 	lowerCamelCase_       (							self:       List[Any]  ):
														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 	lowerCamelCase_       (							self:       List[str]  ):
														lowerCamelCase__      :			Any 						= self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_model(*UpperCamelCase__  )




							@unittest.skip(reason="""Got `CUDA error: misaligned address` with PyTorch 2.0.0."""  )
							def 	lowerCamelCase_       (							self:       Any  ):
														pass




							@unittest.skip(reason="""Swinv2 does not use inputs_embeds"""  )
							def 	lowerCamelCase_       (							self:       Dict  ):
														pass




							def 	lowerCamelCase_       (							self:       Tuple  ):
														lowerCamelCase__      :			int 						= self.model_tester.prepare_config_and_inputs_for_common()

														for model_class in self.all_model_classes:
																					lowerCamelCase__      :			int 						= model_class(UpperCamelCase__  )
																					self.assertIsInstance(model.get_input_embeddings()    ,							(nn.Module)  )
																					lowerCamelCase__      :			Optional[int] 						= model.get_output_embeddings()
																					self.assertTrue(x is None or isinstance(UpperCamelCase__    ,							nn.Linear  )  )




							def 	lowerCamelCase_       (							self:       Optional[int]  ):
														lowerCamelCase__      :			Optional[int] 						= self.model_tester.prepare_config_and_inputs_for_common()

														for model_class in self.all_model_classes:
																					lowerCamelCase__      :			Optional[int] 						= model_class(UpperCamelCase__  )
																					lowerCamelCase__      :			Optional[int] 						= inspect.signature(model.forward  )
																					# signature.parameters is an OrderedDict => so arg_names order is deterministic
																					lowerCamelCase__      :			Tuple 						= [*signature.parameters.keys()]

																					lowerCamelCase__      :			Dict 						= ['pixel_values']
																					self.assertListEqual(arg_names[:1]    ,							UpperCamelCase__  )




							def 	lowerCamelCase_       (							self:       Union[str, Any]  ):
														lowerCamelCase__      :			List[Any] 						= self.model_tester.prepare_config_and_inputs_for_common()
														lowerCamelCase__      :			Optional[int] 						= True

														for model_class in self.all_model_classes:
																					lowerCamelCase__      :			Tuple 						= True
																					lowerCamelCase__      :			str 						= False
																					lowerCamelCase__      :			List[Any] 						= True
																					lowerCamelCase__      :			Dict 						= model_class(UpperCamelCase__  )
																					model.to(UpperCamelCase__  )
																					model.eval()
																					with torch.no_grad():
																												lowerCamelCase__      :			int 						= model(**self._prepare_for_class(UpperCamelCase__    ,							UpperCamelCase__  )  )
																					lowerCamelCase__      :			Dict 						= outputs.attentions
																					lowerCamelCase__      :			Dict 						= len(self.model_tester.depths  )
																					self.assertEqual(len(UpperCamelCase__  )    ,							UpperCamelCase__  )

																					# check that output_attentions also work using config
																					del inputs_dict["output_attentions"]
																					lowerCamelCase__      :			List[str] 						= True
																					lowerCamelCase__      :			Optional[int] 						= config.window_size**2
																					lowerCamelCase__      :			str 						= model_class(UpperCamelCase__  )
																					model.to(UpperCamelCase__  )
																					model.eval()
																					with torch.no_grad():
																												lowerCamelCase__      :			Optional[Any] 						= model(**self._prepare_for_class(UpperCamelCase__    ,							UpperCamelCase__  )  )
																					lowerCamelCase__      :			Optional[Any] 						= outputs.attentions
																					self.assertEqual(len(UpperCamelCase__  )    ,							UpperCamelCase__  )

																					self.assertListEqual(
																					    list(attentions[0].shape[-3:]  )    ,							[self.model_tester.num_heads[0], window_size_squared, window_size_squared]    ,							)
																					lowerCamelCase__      :			Tuple 						= len(UpperCamelCase__  )

																					# Check attention is always last and order is fine
																					lowerCamelCase__      :			str 						= True
																					lowerCamelCase__      :			Union[str, Any] 						= True
																					lowerCamelCase__      :			str 						= model_class(UpperCamelCase__  )
																					model.to(UpperCamelCase__  )
																					model.eval()
																					with torch.no_grad():
																												lowerCamelCase__      :			List[Any] 						= model(**self._prepare_for_class(UpperCamelCase__    ,							UpperCamelCase__  )  )

																					if hasattr(self.model_tester    ,							"""num_hidden_states_types"""  ):
																												lowerCamelCase__      :			Optional[Any] 						= self.model_tester.num_hidden_states_types
																					else:
																												# also another +1 for reshaped_hidden_states
																												lowerCamelCase__      :			Any 						= 2
																					self.assertEqual(out_len + added_hidden_states    ,							len(UpperCamelCase__  )  )

																					lowerCamelCase__      :			Dict 						= outputs.attentions

																					self.assertEqual(len(UpperCamelCase__  )    ,							UpperCamelCase__  )

																					self.assertListEqual(
																					    list(self_attentions[0].shape[-3:]  )    ,							[self.model_tester.num_heads[0], window_size_squared, window_size_squared]    ,							)




							def 	lowerCamelCase_       (							self:       int    ,							UpperCamelCase__:       Optional[int]    ,							UpperCamelCase__:       int    ,							UpperCamelCase__:       Optional[Any]    ,							UpperCamelCase__:       List[Any]  ):
														lowerCamelCase__      :			int 						= model_class(UpperCamelCase__  )
														model.to(UpperCamelCase__  )
														model.eval()

														with torch.no_grad():
																					lowerCamelCase__      :			Optional[Any] 						= model(**self._prepare_for_class(UpperCamelCase__    ,							UpperCamelCase__  )  )

														lowerCamelCase__      :			Optional[Any] 						= outputs.hidden_states

														lowerCamelCase__      :			str 						= getattr(
														    self.model_tester    ,							"""expected_num_hidden_layers"""    ,							len(self.model_tester.depths  ) + 1  )
														self.assertEqual(len(UpperCamelCase__  )    ,							UpperCamelCase__  )

														# Swinv2 has a different seq_length
														lowerCamelCase__      :			int 						= (
														    config.patch_size
														    if isinstance(config.patch_size    ,							collections.abc.Iterable  )
														    else (config.patch_size, config.patch_size)
														)

														lowerCamelCase__      :			List[str] 						= (image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])

														self.assertListEqual(
														    list(hidden_states[0].shape[-2:]  )    ,							[num_patches, self.model_tester.embed_dim]    ,							)

														lowerCamelCase__      :			Union[str, Any] 						= outputs.reshaped_hidden_states
														self.assertEqual(len(UpperCamelCase__  )    ,							UpperCamelCase__  )

														lowerCamelCase__      :			Any 						= reshaped_hidden_states[0].shape
														lowerCamelCase__      :			List[str] 						= (
														    reshaped_hidden_states[0].view(UpperCamelCase__    ,							UpperCamelCase__    ,							height * width  ).permute(0    ,							2    ,							1  )
														)
														self.assertListEqual(
														    list(reshaped_hidden_states.shape[-2:]  )    ,							[num_patches, self.model_tester.embed_dim]    ,							)




							def 	lowerCamelCase_       (							self:       Optional[Any]  ):
														lowerCamelCase__      :			Optional[Any] 						= self.model_tester.prepare_config_and_inputs_for_common()

														lowerCamelCase__      :			str 						= (
														    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:
																					lowerCamelCase__      :			Any 						= True
																					self.check_hidden_states_output(UpperCamelCase__    ,							UpperCamelCase__    ,							UpperCamelCase__    ,							UpperCamelCase__  )

																					# check that output_hidden_states also work using config
																					del inputs_dict["output_hidden_states"]
																					lowerCamelCase__      :			List[str] 						= True

																					self.check_hidden_states_output(UpperCamelCase__    ,							UpperCamelCase__    ,							UpperCamelCase__    ,							UpperCamelCase__  )




							def 	lowerCamelCase_       (							self:       List[str]  ):
														lowerCamelCase__      :			Dict 						= self.model_tester.prepare_config_and_inputs_for_common()
														lowerCamelCase__      :			Any 						= 3

														lowerCamelCase__      :			int 						= (
														    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)
														)
														lowerCamelCase__      :			str 						= (
														    config.patch_size
														    if isinstance(config.patch_size    ,							collections.abc.Iterable  )
														    else (config.patch_size, config.patch_size)
														)

														lowerCamelCase__      :			str 						= image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
														lowerCamelCase__      :			Any 						= image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

														for model_class in self.all_model_classes:
																					lowerCamelCase__      :			str 						= True
																					self.check_hidden_states_output(UpperCamelCase__    ,							UpperCamelCase__    ,							UpperCamelCase__    ,							(padded_height, padded_width)  )

																					# check that output_hidden_states also work using config
																					del inputs_dict["output_hidden_states"]
																					lowerCamelCase__      :			Any 						= True
																					self.check_hidden_states_output(UpperCamelCase__    ,							UpperCamelCase__    ,							UpperCamelCase__    ,							(padded_height, padded_width)  )




							def 	lowerCamelCase_       (							self:       Dict  ):
														lowerCamelCase__      :			Any 						= self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_masked_image_modeling(*UpperCamelCase__  )




							def 	lowerCamelCase_       (							self:       Union[str, Any]  ):
														lowerCamelCase__      :			Dict 						= self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_image_classification(*UpperCamelCase__  )




							@slow
							def 	lowerCamelCase_       (							self:       Union[str, Any]  ):







														for model_name in SWINV2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																					lowerCamelCase__      :			List[str] 						= SwinvaModel.from_pretrained(UpperCamelCase__  )
																					self.assertIsNotNone(UpperCamelCase__  )




							def 	lowerCamelCase_       (							self:       Any  ):
														lowerCamelCase__      :			Optional[int] 						= self.model_tester.prepare_config_and_inputs_for_common()

														lowerCamelCase__      :			Optional[int] 						= _config_zero_init(UpperCamelCase__  )
														for model_class in self.all_model_classes:
																					lowerCamelCase__      :			int 						= model_class(config=UpperCamelCase__  )
																					for name, param in model.named_parameters():
																												if "embeddings" not in name and "logit_scale" 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_vision
@require_torch
class _lowercase			(       unittest.TestCase	):




							@cached_property
							def 	lowerCamelCase_       (							self:       Union[str, Any]  ):
														return (
														    AutoImageProcessor.from_pretrained("""microsoft/swinv2-tiny-patch4-window8-256"""  )
														    if is_vision_available()
														    else None
														)




							@slow
							def 	lowerCamelCase_       (							self:       Dict  ):
														lowerCamelCase__      :			Tuple 						= SwinvaForImageClassification.from_pretrained("""microsoft/swinv2-tiny-patch4-window8-256"""  ).to(
														    UpperCamelCase__  )
														lowerCamelCase__      :			Dict 						= self.default_image_processor

														lowerCamelCase__      :			List[str] 						= Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""  )
														lowerCamelCase__      :			Any 						= image_processor(images=UpperCamelCase__    ,							return_tensors="""pt"""  ).to(UpperCamelCase__  )

														# forward pass
														with torch.no_grad():
																					lowerCamelCase__      :			Union[str, Any] 						= model(**UpperCamelCase__  )

														# verify the logits
														lowerCamelCase__      :			List[str] 						= torch.Size((1, 1_000)  )
														self.assertEqual(outputs.logits.shape    ,							UpperCamelCase__  )
														lowerCamelCase__      :			Optional[Any] 						= torch.tensor([-0.3_947, -0.4_306, 0.0_026]  ).to(UpperCamelCase__  )
														self.assertTrue(torch.allclose(outputs.logits[0, :3]    ,							UpperCamelCase__    ,							atol=1e-4  )  )









'''simple docstring'''







import argparse
import os
import re

import packaging.version


_A			:    List[str]					  ='''examples/'''
_A			:    Any					  ={
    '''examples''': (re.compile(r'''^check_min_version\("[^"]+"\)\s*$''', re.MULTILINE), '''check_min_version("VERSION")\n'''),
    '''init''': (re.compile(r'''^__version__\s+=\s+"([^"]+)"\s*$''', re.MULTILINE), '''__version__ = "VERSION"\n'''),
    '''setup''': (re.compile(r'''^(\s*)version\s*=\s*"[^"]+",''', re.MULTILINE), r'''\1version="VERSION",'''),
    '''doc''': (re.compile(r'''^(\s*)release\s*=\s*"[^"]+"$''', re.MULTILINE), '''release = "VERSION"\n'''),
}
_A			:    int					  ={
    '''init''': '''src/transformers/__init__.py''',
    '''setup''': '''setup.py''',
}
_A			:    int					  ='''README.md'''





def 				SCREAMING_SNAKE_CASE_ (UpperCamelCase       ,    UpperCamelCase       ,    UpperCamelCase   )   -> str:
							with open(UpperCamelCase       ,    """r"""       ,    encoding="""utf-8"""       ,    newline="""\n"""   ) as f:
														lowerCamelCase__      :			List[str] 						= f.read()
							lowerCamelCase__						,	lowerCamelCase__      :			Optional[int] 						= REPLACE_PATTERNS[pattern]
							lowerCamelCase__      :			Dict 						= replace.replace("""VERSION"""       ,    UpperCamelCase   )
							lowerCamelCase__      :			str 						= re_pattern.sub(UpperCamelCase       ,    UpperCamelCase   )
							with open(UpperCamelCase       ,    """w"""       ,    encoding="""utf-8"""       ,    newline="""\n"""   ) as f:
														f.write(UpperCamelCase   )





def 				SCREAMING_SNAKE_CASE_ (UpperCamelCase   )   -> str:
							for folder, directories, fnames in os.walk(UpperCamelCase   ):
														# Removing some of the folders with non-actively maintained examples from the walk
														if "research_projects" in directories:
																					directories.remove("""research_projects"""   )
														if "legacy" in directories:
																					directories.remove("""legacy"""   )
														for fname in fnames:
																					if fname.endswith(""".py"""   ):
																												update_version_in_file(os.path.join(UpperCamelCase       ,    UpperCamelCase   )       ,    UpperCamelCase       ,    pattern="""examples"""   )





def 				SCREAMING_SNAKE_CASE_ (UpperCamelCase       ,    UpperCamelCase=False   )   -> List[Any]:
							for pattern, fname in REPLACE_FILES.items():
														update_version_in_file(UpperCamelCase       ,    UpperCamelCase       ,    UpperCamelCase   )
							if not patch:
														update_version_in_examples(UpperCamelCase   )





def 				SCREAMING_SNAKE_CASE_ ()   -> Optional[Any]:
							lowerCamelCase__      :			Dict 						= """🤗 Transformers currently provides the following architectures"""
							lowerCamelCase__      :			Dict 						= """1. Want to contribute a new model?"""
							with open(UpperCamelCase       ,    """r"""       ,    encoding="""utf-8"""       ,    newline="""\n"""   ) as f:
														lowerCamelCase__      :			int 						= f.readlines()

							# Find the start of the list.
							lowerCamelCase__      :			Optional[int] 						= 0
							while not lines[start_index].startswith(_start_prompt   ):
														start_index += 1
							start_index += 1

							lowerCamelCase__      :			Optional[Any] 						= start_index
							# Update the lines in the model list.
							while not lines[index].startswith(_end_prompt   ):
														if lines[index].startswith("""1."""   ):
																					lowerCamelCase__      :			List[Any] 						= lines[index].replace(
																					    """https://huggingface.co/docs/transformers/main/model_doc"""       ,    """https://huggingface.co/docs/transformers/model_doc"""       ,    )
														index += 1

							with open(UpperCamelCase       ,    """w"""       ,    encoding="""utf-8"""       ,    newline="""\n"""   ) as f:
														f.writelines(UpperCamelCase   )





def 				SCREAMING_SNAKE_CASE_ ()   -> Optional[Any]:
							with open(REPLACE_FILES["""init"""]       ,    """r"""   ) as f:
														lowerCamelCase__      :			int 						= f.read()
							lowerCamelCase__      :			Optional[Any] 						= REPLACE_PATTERNS["""init"""][0].search(UpperCamelCase   ).groups()[0]
							return packaging.version.parse(UpperCamelCase   )





def 				SCREAMING_SNAKE_CASE_ (UpperCamelCase=False   )   -> List[Any]:
							lowerCamelCase__      :			Union[str, Any] 						= get_version()
							if patch and default_version.is_devrelease:
														raise ValueError("""Can't create a patch version from the dev branch, checkout a released version!"""   )
							if default_version.is_devrelease:
														lowerCamelCase__      :			List[str] 						= default_version.base_version
							elif patch:
														lowerCamelCase__      :			Any 						= f'''{default_version.major}.{default_version.minor}.{default_version.micro + 1}'''
							else:
														lowerCamelCase__      :			List[Any] 						= f'''{default_version.major}.{default_version.minor + 1}.0'''

							# Now let's ask nicely if that's the right one.
							lowerCamelCase__      :			Any 						= input(f'''Which version are you releasing? [{default_version}]'''   )
							if len(UpperCamelCase   ) == 0:
														lowerCamelCase__      :			Optional[int] 						= default_version

							print(f'''Updating version to {version}.'''   )
							global_version_update(UpperCamelCase       ,    patch=UpperCamelCase   )
							if not patch:
														print("""Cleaning main README, don't forget to run `make fix-copies`."""   )
														clean_main_ref_in_model_list()





def 				SCREAMING_SNAKE_CASE_ ()   -> List[str]:
							lowerCamelCase__      :			Optional[int] 						= get_version()
							lowerCamelCase__      :			Any 						= f'''{current_version.major}.{current_version.minor + 1}.0.dev0'''
							lowerCamelCase__      :			Any 						= current_version.base_version

							# Check with the user we got that right.
							lowerCamelCase__      :			List[Any] 						= input(f'''Which version are we developing now? [{dev_version}]'''   )
							if len(UpperCamelCase   ) == 0:
														lowerCamelCase__      :			Dict 						= dev_version

							print(f'''Updating version to {version}.'''   )
							global_version_update(UpperCamelCase   )
							print("""Cleaning main README, don't forget to run `make fix-copies`."""   )
							clean_main_ref_in_model_list()


if __name__ == "__main__":
			_A			:    List[Any]					  =argparse.ArgumentParser()
			parser.add_argument('''--post_release''', action='''store_true''', help='''Whether this is pre or post release.''')
			parser.add_argument('''--patch''', action='''store_true''', help='''Whether or not this is a patch release.''')
			_A			:    List[str]					  =parser.parse_args()
			if not args.post_release:
						pre_release_work(patch=args.patch)
			elif args.patch:
						print('''Nothing to do after a patch :-)''')
			else:
						post_release_work()

