



import argparse

import torch

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


logging.set_verbosity_info()






def  UpperCAmelCase_       (		lowercase__       ,	lowercase__       ,	lowercase__       ):


     '''simple docstring'''







     a_       		=RemBertConfig.from_json_file(UpperCAmelCase__       )
     print("Building PyTorch model from configuration: {}".format(str(UpperCAmelCase__       )       )       )
     a_       		=RemBertModel(UpperCAmelCase__       )

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

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


if __name__ == "__main__":
  lowercase							       =			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.'''
  )
  lowercase							       =			parser.parse_args()
  convert_rembert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.rembert_config_file, args.pytorch_dump_path)







'''simple docstring'''


from __future__ import annotations






def  UpperCAmelCase_       (		lowercase__       ,	lowercase__       ):


     '''simple docstring'''







     if b == 0:
          return (1, 0)
     ((a_)		,						(a_))       		=extended_euclid(lowercase__       ,	a % b       )
     a_       		=a // b
     return (y, x - k * y)






def  UpperCAmelCase_       (		lowercase__       ,	lowercase__       ,	lowercase__       ,	lowercase__       ):


     '''simple docstring'''







     ((a_)		,						(a_))       		=extended_euclid(lowercase__       ,	lowercase__       )
     a_       		=na * na
     a_       		=ra * x * na + ra * y * na
     return (n % m + m) % m






def  UpperCAmelCase_       (		lowercase__       ,	lowercase__       ):


     '''simple docstring'''







     ((a_)		,						(a_))       		=extended_euclid(lowercase__       ,	lowercase__       )
     if b < 0:
          a_       		=(b % n + n) % n
     return b






def  UpperCAmelCase_       (		lowercase__       ,	lowercase__       ,	lowercase__       ,	lowercase__       ):


     '''simple docstring'''







     a_		,						a_       		=invert_modulo(lowercase__       ,	lowercase__       ), invert_modulo(lowercase__       ,	lowercase__       )
     a_       		=na * na
     a_       		=ra * x * na + ra * y * na
     return (n % m + m) % m


if __name__ == "__main__":
  from doctest import testmod

  testmod(name='''chinese_remainder_theorem''', verbose=True)
  testmod(name='''chinese_remainder_theorem2''', verbose=True)
  testmod(name='''invert_modulo''', verbose=True)
  testmod(name='''extended_euclid''', verbose=True)


