


import argparse

import torch

from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert
from transformers.utils import logging


logging.set_verbosity_info()







def 	SCREAMING_SNAKE_CASE_						(      __A			:      str  ,   __A			:      Dict  ,   __A			:      Union[str, Any]    )     ->		int:

       """simple docstring"""

       a_ :		str							=  RemBertConfig.from_json_file(__A    )
       print('Building PyTorch model from configuration: {}'.format(str(__A    )    )    )
       a_ :		List[str]							=  RemBertModel(__A    )

       # Load weights from tf checkpoint
       load_tf_weights_in_rembert(__A  ,   __A  ,   __A    )

       # Save pytorch-model
       print('Save PyTorch model to {}'.format(__A    )    )
       torch.save(model.state_dict()  ,   __A    )


if __name__ == "__main__":
   UpperCAmelCase_				:			Optional[int]   =	argparse.ArgumentParser()
   # Required parameters
   parser.add_argument(
       '--tf_checkpoint_path', default=None, type=str, required=True, help='Path to the TensorFlow checkpoint path.'
   )
   parser.add_argument(
       '--rembert_config_file',
       default=None,
       type=str,
       required=True,
       help=(
           'The config json file corresponding to the pre-trained RemBERT model. \n'
           'This specifies the model architecture.'
       ),
   )
   parser.add_argument(
       '--pytorch_dump_path', default=None, type=str, required=True, help='Path to the output PyTorch model.'
   )
   UpperCAmelCase_				:			Optional[int]   =	parser.parse_args()
   convert_rembert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.rembert_config_file, args.pytorch_dump_path)






def 	SCREAMING_SNAKE_CASE_						(      __A			:      list    )     ->		bool:

       """simple docstring"""

       if not isinstance(__A  ,   __A    ):
              raise ValueError('Input series is not valid, valid series - [2, 4, 6]'    )
       if len(__A    ) == 0:
              raise ValueError('Input list must be a non empty list'    )
       if len(__A    ) == 1:
              return True
       a_ :		Tuple							=  series[1] - series[0]
       for index in range(len(__A    ) - 1    ):
              if series[index + 1] - series[index] != common_diff:
                     return False
       return True







def 	SCREAMING_SNAKE_CASE_						(      __A			:      list    )     ->		float:

       """simple docstring"""

       if not isinstance(__A  ,   __A    ):
              raise ValueError('Input series is not valid, valid series - [2, 4, 6]'    )
       if len(__A    ) == 0:
              raise ValueError('Input list must be a non empty list'    )
       a_ :		str							=  0
       for val in series:
              answer += val
       return answer / len(__A    )


if __name__ == "__main__":
   import doctest

   doctest.testmod()


