import math
import os
import unittest

from transformers import MegatronBertConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
      import torch

      from transformers import (
          MODEL_FOR_PRETRAINING_MAPPING,
          MegatronBertForCausalLM,
          MegatronBertForMaskedLM,
          MegatronBertForMultipleChoice,
          MegatronBertForNextSentencePrediction,
          MegatronBertForPreTraining,
          MegatronBertForQuestionAnswering,
          MegatronBertForSequenceClassification,
          MegatronBertForTokenClassification,
          MegatronBertModel,
      )



class 		UpperCamelCase__  :
   def __init__(self			: Optional[Any] ,    snake_case_			: str ,    snake_case_			: List[str]=1_3 ,    snake_case_			: Union[str, Any]=7 ,    snake_case_			: str=True ,    snake_case_			: Union[str, Any]=True ,    snake_case_			: Dict=True ,    snake_case_			: Dict=True ,    snake_case_			: Optional[Any]=9_9 ,    snake_case_			: Optional[Any]=6_4 ,    snake_case_			: Union[str, Any]=3_2 ,    snake_case_			: Any=5 ,    snake_case_			: Dict=4 ,    snake_case_			: List[str]=3_7 ,    snake_case_			: str="gelu" ,    snake_case_			: Dict=0.1 ,    snake_case_			: Union[str, Any]=0.1 ,    snake_case_			: List[str]=5_1_2 ,    snake_case_			: Tuple=1_6 ,    snake_case_			: Union[str, Any]=2 ,    snake_case_			: Dict=0.02 ,    snake_case_			: Any=3 ,    snake_case_			: Optional[int]=4 ,    snake_case_			: Optional[Any]=None ,    ):
    __a			:  Tuple		    =  parent
    __a			:  Dict		    =  batch_size
    __a			:  Union[str, Any]		    =  seq_length
    __a			:  str		    =  is_training
    __a			:  Dict		    =  use_input_mask
    __a			:  Tuple		    =  use_token_type_ids
    __a			:  str		    =  use_labels
    __a			:  int		    =  vocab_size
    __a			:  List[str]		    =  hidden_size
    __a			:  Dict		    =  embedding_size
    __a			:  Dict		    =  num_hidden_layers
    __a			:  Optional[int]		    =  num_attention_heads
    __a			:  int		    =  intermediate_size
    __a			:  Union[str, Any]		    =  hidden_act
    __a			:  Optional[Any]		    =  hidden_dropout_prob
    __a			:  str		    =  attention_probs_dropout_prob
    __a			:  str		    =  max_position_embeddings
    __a			:  List[str]		    =  type_vocab_size
    __a			:  Tuple		    =  type_sequence_label_size
    __a			:  Tuple		    =  initializer_range
    __a			:  List[str]		    =  num_labels
    __a			:  Dict		    =  num_choices
    __a			:  List[str]		    =  scope
   def 				lowerCAmelCase      (self			: Dict       ):
    __a			:  Union[str, Any]		    =  ids_tensor([self.batch_size, self.seq_length] ,    self.vocab_size       )

    __a			:  Optional[Any]		    =  None
    if self.use_input_mask:
     __a			:  Any		    =  random_attention_mask([self.batch_size, self.seq_length]       )

    __a			:  List[Any]		    =  None
    if self.use_token_type_ids:
     __a			:  Tuple		    =  ids_tensor([self.batch_size, self.seq_length] ,    self.type_vocab_size       )

    __a			:  str		    =  None
    __a			:  Tuple		    =  None
    __a			:  Union[str, Any]		    =  None
    if self.use_labels:
     __a			:  int		    =  ids_tensor([self.batch_size] ,    self.type_sequence_label_size       )
     __a			:  str		    =  ids_tensor([self.batch_size, self.seq_length] ,    self.num_labels       )
     __a			:  List[Any]		    =  ids_tensor([self.batch_size] ,    self.num_choices       )

    __a			:  Optional[int]		    =  self.get_config()

    return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
   def 				lowerCAmelCase      (self			: Tuple       ):
    return MegatronBertConfig(
        vocab_size=self.vocab_size ,    hidden_size=self.hidden_size ,    num_hidden_layers=self.num_hidden_layers ,    num_attention_heads=self.num_attention_heads ,    intermediate_size=self.intermediate_size ,    embedding_size=self.embedding_size ,    hidden_act=self.hidden_act ,    hidden_dropout_prob=self.hidden_dropout_prob ,    attention_probs_dropout_prob=self.attention_probs_dropout_prob ,    max_position_embeddings=self.max_position_embeddings ,    type_vocab_size=self.type_vocab_size ,    is_decoder=snake_case_ ,    initializer_range=self.initializer_range ,    )
   def 				lowerCAmelCase      (self			: str ,    snake_case_			: List[Any] ,    snake_case_			: str ,    snake_case_			: List[Any] ,    snake_case_			: Optional[int] ,    snake_case_			: List[str] ,    snake_case_			: Any ,    snake_case_			: Tuple       ):
    __a			:  Tuple		    =  MegatronBertModel(config=snake_case_       )
    model.to(snake_case_       )
    model.eval()
    __a			:  Tuple		    =  model(snake_case_ ,    attention_mask=snake_case_ ,    token_type_ids=snake_case_       )
    __a			:  Dict		    =  model(snake_case_ ,    token_type_ids=snake_case_       )
    __a			:  Tuple		    =  model(snake_case_       )

    self.parent.assertEqual(result.last_hidden_state.shape ,    (self.batch_size, self.seq_length, self.hidden_size)       )
    self.parent.assertEqual(result.pooler_output.shape ,    (self.batch_size, self.hidden_size)       )
   def 				lowerCAmelCase      (self			: Any ,    snake_case_			: Optional[int] ,    snake_case_			: Optional[Any] ,    snake_case_			: Dict ,    snake_case_			: Optional[Any] ,    snake_case_			: Optional[Any] ,    snake_case_			: Dict ,    snake_case_			: str       ):
    __a			:  Optional[Any]		    =  MegatronBertForMaskedLM(config=snake_case_       )
    model.to(snake_case_       )
    model.eval()
    __a			:  Any		    =  model(snake_case_ ,    attention_mask=snake_case_ ,    token_type_ids=snake_case_ ,    labels=snake_case_       )
    self.parent.assertEqual(result.logits.shape ,    (self.batch_size, self.seq_length, self.vocab_size)       )
   def 				lowerCAmelCase      (self			: Any ,    snake_case_			: Tuple ,    snake_case_			: str ,    snake_case_			: Optional[int] ,    snake_case_			: Union[str, Any] ,    snake_case_			: Optional[int] ,    snake_case_			: Optional[int] ,    snake_case_			: Any       ):
    __a			:  Optional[Any]		    =  MegatronBertForCausalLM(config=snake_case_       )
    model.to(snake_case_       )
    model.eval()
    __a			:  int		    =  model(snake_case_ ,    attention_mask=snake_case_ ,    token_type_ids=snake_case_ ,    labels=snake_case_       )
    self.parent.assertEqual(result.logits.shape ,    (self.batch_size, self.seq_length, self.vocab_size)       )
   def 				lowerCAmelCase      (self			: Any ,    snake_case_			: List[Any] ,    snake_case_			: Union[str, Any] ,    snake_case_			: List[Any] ,    snake_case_			: List[Any] ,    snake_case_			: Optional[Any] ,    snake_case_			: Optional[Any] ,    snake_case_			: Union[str, Any]       ):
    __a			:  Dict		    =  MegatronBertForNextSentencePrediction(config=snake_case_       )
    model.to(snake_case_       )
    model.eval()
    __a			:  Tuple		    =  model(
        snake_case_ ,    attention_mask=snake_case_ ,    token_type_ids=snake_case_ ,    labels=snake_case_ ,    )
    self.parent.assertEqual(result.logits.shape ,    (self.batch_size, 2)       )
   def 				lowerCAmelCase      (self			: Any ,    snake_case_			: List[Any] ,    snake_case_			: Union[str, Any] ,    snake_case_			: Union[str, Any] ,    snake_case_			: List[str] ,    snake_case_			: Dict ,    snake_case_			: List[str] ,    snake_case_			: Optional[Any]       ):
    __a			:  Union[str, Any]		    =  MegatronBertForPreTraining(config=snake_case_       )
    model.to(snake_case_       )
    model.eval()
    __a			:  str		    =  model(
        snake_case_ ,    attention_mask=snake_case_ ,    token_type_ids=snake_case_ ,    labels=snake_case_ ,    next_sentence_label=snake_case_ ,    )
    self.parent.assertEqual(result.prediction_logits.shape ,    (self.batch_size, self.seq_length, self.vocab_size)       )
    self.parent.assertEqual(result.seq_relationship_logits.shape ,    (self.batch_size, 2)       )
   def 				lowerCAmelCase      (self			: Dict ,    snake_case_			: List[str] ,    snake_case_			: str ,    snake_case_			: List[Any] ,    snake_case_			: Union[str, Any] ,    snake_case_			: List[Any] ,    snake_case_			: str ,    snake_case_			: str       ):
    __a			:  Optional[Any]		    =  MegatronBertForQuestionAnswering(config=snake_case_       )
    model.to(snake_case_       )
    model.eval()
    __a			:  Optional[int]		    =  model(
        snake_case_ ,    attention_mask=snake_case_ ,    token_type_ids=snake_case_ ,    start_positions=snake_case_ ,    end_positions=snake_case_ ,    )
    self.parent.assertEqual(result.start_logits.shape ,    (self.batch_size, self.seq_length)       )
    self.parent.assertEqual(result.end_logits.shape ,    (self.batch_size, self.seq_length)       )
   def 				lowerCAmelCase      (self			: Optional[int] ,    snake_case_			: List[str] ,    snake_case_			: Optional[int] ,    snake_case_			: str ,    snake_case_			: Tuple ,    snake_case_			: Optional[Any] ,    snake_case_			: str ,    snake_case_			: Tuple       ):
    __a			:  Optional[int]		    =  self.num_labels
    __a			:  Optional[int]		    =  MegatronBertForSequenceClassification(snake_case_       )
    model.to(snake_case_       )
    model.eval()
    __a			:  Tuple		    =  model(snake_case_ ,    attention_mask=snake_case_ ,    token_type_ids=snake_case_ ,    labels=snake_case_       )
    self.parent.assertEqual(result.logits.shape ,    (self.batch_size, self.num_labels)       )
   def 				lowerCAmelCase      (self			: Optional[int] ,    snake_case_			: List[str] ,    snake_case_			: List[str] ,    snake_case_			: Dict ,    snake_case_			: Tuple ,    snake_case_			: List[Any] ,    snake_case_			: Optional[int] ,    snake_case_			: Optional[int]       ):
    __a			:  Union[str, Any]		    =  self.num_labels
    __a			:  Dict		    =  MegatronBertForTokenClassification(config=snake_case_       )
    model.to(snake_case_       )
    model.eval()
    __a			:  List[str]		    =  model(snake_case_ ,    attention_mask=snake_case_ ,    token_type_ids=snake_case_ ,    labels=snake_case_       )
    self.parent.assertEqual(result.logits.shape ,    (self.batch_size, self.seq_length, self.num_labels)       )
   def 				lowerCAmelCase      (self			: int ,    snake_case_			: Dict ,    snake_case_			: Any ,    snake_case_			: str ,    snake_case_			: List[Any] ,    snake_case_			: Union[str, Any] ,    snake_case_			: int ,    snake_case_			: str       ):
    __a			:  str		    =  self.num_choices
    __a			:  Union[str, Any]		    =  MegatronBertForMultipleChoice(config=snake_case_       )
    model.to(snake_case_       )
    model.eval()
    __a			:  Dict		    =  input_ids.unsqueeze(1       ).expand(-1 ,    self.num_choices ,    -1       ).contiguous()
    __a			:  Optional[Any]		    =  token_type_ids.unsqueeze(1       ).expand(-1 ,    self.num_choices ,    -1       ).contiguous()
    __a			:  Any		    =  input_mask.unsqueeze(1       ).expand(-1 ,    self.num_choices ,    -1       ).contiguous()
    __a			:  Any		    =  model(
        snake_case_ ,    attention_mask=snake_case_ ,    token_type_ids=snake_case_ ,    labels=snake_case_ ,    )
    self.parent.assertEqual(result.logits.shape ,    (self.batch_size, self.num_choices)       )







   def 				lowerCAmelCase      (self			: Optional[Any]       ):
    __a			:  Tuple		    =  self.prepare_config_and_inputs()
    (
        __a	
    )			:  str		    =  config_and_inputs
    __a			:  Dict		    =  {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
    return config, inputs_dict





@require_torch
class 		UpperCamelCase__  (	__lowercase   ,__lowercase   ,unittest.TestCase   ):
   _SCREAMING_SNAKE_CASE				:							Any     	=				(
       (
           MegatronBertModel,
           MegatronBertForMaskedLM,
           MegatronBertForCausalLM,
           MegatronBertForMultipleChoice,
           MegatronBertForNextSentencePrediction,
           MegatronBertForPreTraining,
           MegatronBertForQuestionAnswering,
           MegatronBertForSequenceClassification,
           MegatronBertForTokenClassification,
       )
       if is_torch_available()
       else ()
   )
   _SCREAMING_SNAKE_CASE				:							Tuple     	=				(
       {
           "feature-extraction": MegatronBertModel,
           "fill-mask": MegatronBertForMaskedLM,
           "question-answering": MegatronBertForQuestionAnswering,
           "text-classification": MegatronBertForSequenceClassification,
           "text-generation": MegatronBertForCausalLM,
           "token-classification": MegatronBertForTokenClassification,
           "zero-shot": MegatronBertForSequenceClassification,
       }
       if is_torch_available()
       else {}
   )
   _SCREAMING_SNAKE_CASE				:							Optional[Any]     	=				True
   # test_resize_embeddings = False
   _SCREAMING_SNAKE_CASE				:							List[Any]     	=				False
   def 				lowerCAmelCase      (self			: Any ,    snake_case_			: Optional[Any] ,    snake_case_			: int ,    snake_case_			: Dict=False       ):
    __a			:  List[str]		    =  super()._prepare_for_class(snake_case_ ,    snake_case_ ,    return_labels=snake_case_       )

    if return_labels:
     if model_class in get_values(snake_case_       ):
      __a			:  Optional[Any]		    =  torch.zeros(
          (self.model_tester.batch_size, self.model_tester.seq_length) ,    dtype=torch.long ,    device=snake_case_       )
      __a			:  Any		    =  torch.zeros(
          self.model_tester.batch_size ,    dtype=torch.long ,    device=snake_case_       )
    return inputs_dict
   def 				lowerCAmelCase      (self			: Tuple       ):
    __a			:  List[Any]		    =  MegatronBertModelTester(self       )
    __a			:  Any		    =  ConfigTester(self ,    config_class=snake_case_ ,    hidden_size=3_7       )
   def 				lowerCAmelCase      (self			: List[Any]       ):
    self.config_tester.run_common_tests()
   def 				lowerCAmelCase      (self			: Optional[Any]       ):
    __a			:  Union[str, Any]		    =  self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_megatron_bert_model(*snake_case_       )
   def 				lowerCAmelCase      (self			: int       ):
    __a			:  Dict		    =  self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_megatron_bert_for_masked_lm(*snake_case_       )
   def 				lowerCAmelCase      (self			: Optional[Any]       ):
    __a			:  List[str]		    =  self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_megatron_bert_for_multiple_choice(*snake_case_       )
   def 				lowerCAmelCase      (self			: str       ):
    __a			:  str		    =  self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_megatron_bert_for_next_sequence_prediction(*snake_case_       )
   def 				lowerCAmelCase      (self			: Any       ):
    __a			:  Optional[Any]		    =  self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_megatron_bert_for_pretraining(*snake_case_       )
   def 				lowerCAmelCase      (self			: Optional[int]       ):
    __a			:  List[str]		    =  self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_megatron_bert_for_question_answering(*snake_case_       )
   def 				lowerCAmelCase      (self			: List[Any]       ):
    __a			:  List[Any]		    =  self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_megatron_bert_for_sequence_classification(*snake_case_       )







   def 				lowerCAmelCase      (self			: Dict       ):
    __a			:  int		    =  self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_megatron_bert_for_token_classification(*snake_case_       )





def        __UpperCamelCase					(    lowerCAmelCase__							:    str  ):
 return torch.tensor(
     lowerCAmelCase__  ,       dtype=torch.long  ,       device=lowerCAmelCase__  ,       )


lowercase__          =1e-4



@require_torch
@require_sentencepiece
@require_tokenizers
class 		UpperCamelCase__  (	unittest.TestCase   ):
   @slow
   @unittest.skip('''Model is not available.'''       )
   def 				lowerCAmelCase      (self			: str       ):
    __a			:  List[str]		    =  '''nvidia/megatron-bert-uncased-345m'''
    if "MYDIR" in os.environ:
     __a			:  Tuple		    =  os.path.join(os.environ['''MYDIR'''] ,    snake_case_       )
    __a			:  Any		    =  MegatronBertModel.from_pretrained(snake_case_       )
    model.to(snake_case_       )
    model.half()
    __a			:  Union[str, Any]		    =  _long_tensor([[1_0_1, 7_1_1_0, 1_0_0_5, 1_0_5_6, 2_0_2_3, 1_1_3_3_3, 1_7_4_1_3, 1_0_2_9, 1_0_2]]       )
    with torch.no_grad():
     __a			:  List[str]		    =  model(snake_case_       )[0]
    __a			:  Optional[int]		    =  torch.Size((1, 9, 1_0_2_4)       )
    self.assertEqual(output.shape ,    snake_case_       )

    __a			:  Tuple		    =  [-0.6040, -0.2517, -0.1025, 0.3420, -0.6758, -0.0017, -0.1089, -0.1990, 0.5728]
    for ii in range(3       ):
     for jj in range(3       ):
      __a			:  Optional[int]		    =  output[0, ii, jj]
      __a			:  Any		    =  expected[3 * ii + jj]
      __a			:  Union[str, Any]		    =  '''ii={} jj={} a={} b={}'''.format(snake_case_ ,    snake_case_ ,    snake_case_ ,    snake_case_       )
      self.assertTrue(math.isclose(snake_case_ ,    snake_case_ ,    rel_tol=snake_case_ ,    abs_tol=snake_case_       ) ,    msg=snake_case_       )


import argparse
import os
import re

import packaging.version


lowercase__          ='examples/'
lowercase__          ={
    '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'),
}
lowercase__          ={
    'init': 'src/transformers/__init__.py',
    'setup': 'setup.py',
}
lowercase__          ='README.md'




def        __UpperCamelCase					(    lowerCAmelCase__							:    List[Any]  ,       lowerCAmelCase__							:    Dict  ,       lowerCAmelCase__							:    Tuple  ):
 with open(lowerCAmelCase__  ,       '''r'''  ,       encoding='''utf-8'''  ,       newline='''\n'''  ) as f:
  __a			:  Tuple		    =  f.read()
 __a    ,	__a			:  Optional[int]		    =  REPLACE_PATTERNS[pattern]
 __a			:  List[Any]		    =  replace.replace('''VERSION'''  ,       lowerCAmelCase__  )
 __a			:  Any		    =  re_pattern.sub(lowerCAmelCase__  ,       lowerCAmelCase__  )
 with open(lowerCAmelCase__  ,       '''w'''  ,       encoding='''utf-8'''  ,       newline='''\n'''  ) as f:
  f.write(lowerCAmelCase__  )




def        __UpperCamelCase					(    lowerCAmelCase__							:    Tuple  ):
 for folder, directories, fnames in os.walk(lowerCAmelCase__  ):
  # 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(lowerCAmelCase__  ,       lowerCAmelCase__  )  ,       lowerCAmelCase__  ,       pattern='''examples'''  )




def        __UpperCamelCase					(    lowerCAmelCase__							:    Optional[int]  ,       lowerCAmelCase__							:    Dict=False  ):
 for pattern, fname in REPLACE_FILES.items():
  update_version_in_file(lowerCAmelCase__  ,       lowerCAmelCase__  ,       lowerCAmelCase__  )
 if not patch:
  update_version_in_examples(lowerCAmelCase__  )




def        __UpperCamelCase					(    ):
 __a			:  Optional[int]		    =  '''🤗 Transformers currently provides the following architectures'''
 __a			:  int		    =  '''1. Want to contribute a new model?'''
 with open(lowerCAmelCase__  ,       '''r'''  ,       encoding='''utf-8'''  ,       newline='''\n'''  ) as f:
  __a			:  Tuple		    =  f.readlines()

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

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

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




def        __UpperCamelCase					(    ):
 with open(REPLACE_FILES['''init''']  ,       '''r'''  ) as f:
  __a			:  Optional[int]		    =  f.read()
 __a			:  str		    =  REPLACE_PATTERNS['''init'''][0].search(lowerCAmelCase__  ).groups()[0]
 return packaging.version.parse(lowerCAmelCase__  )




def        __UpperCamelCase					(    lowerCAmelCase__							:    Union[str, Any]=False  ):
 __a			:  str		    =  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:
  __a			:  Union[str, Any]		    =  default_version.base_version
 elif patch:
  __a			:  Tuple		    =  f"{default_version.major}.{default_version.minor}.{default_version.micro + 1}"
 else:
  __a			:  List[str]		    =  f"{default_version.major}.{default_version.minor + 1}.0"

 # Now let's ask nicely if that's the right one.
 __a			:  List[str]		    =  input(f"Which version are you releasing? [{default_version}]"  )
 if len(lowerCAmelCase__  ) == 0:
  __a			:  Tuple		    =  default_version

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




def        __UpperCamelCase					(    ):
 __a			:  Dict		    =  get_version()
 __a			:  str		    =  f"{current_version.major}.{current_version.minor + 1}.0.dev0"
 __a			:  Any		    =  current_version.base_version

 # Check with the user we got that right.
 __a			:  Any		    =  input(f"Which version are we developing now? [{dev_version}]"  )
 if len(lowerCAmelCase__  ) == 0:
  __a			:  Any		    =  dev_version

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


if __name__ == "__main__":
      lowercase__          =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.')
      lowercase__          =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()
