






# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.:
#   python ./utils/get_modified_files.py utils src tests examples
#
# it uses git to find the forking point and which files were modified - i.e. files not under git won't be considered
# since the output of this script is fed into Makefile commands it doesn't print a newline after the results

import re
import subprocess
import sys


SCREAMING_SNAKE_CASE 							=						subprocess.check_output('git merge-base main HEAD'.split()).decode('utf-8')
SCREAMING_SNAKE_CASE 							=						(
    subprocess.check_output(F'git diff --diff-filter=d --name-only {fork_point_sha}'.split()).decode('utf-8').split()
)

SCREAMING_SNAKE_CASE 							=						'|'.join(sys.argv[1:])
SCREAMING_SNAKE_CASE 							=						re.compile(RF'^({joined_dirs}).*?\.py$')

SCREAMING_SNAKE_CASE 							=						[x for x in modified_files if regex.match(x)]
print(' '.join(relevant_modified_files), end='')












import argparse

import torch

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


logging.set_verbosity_info()

def      _lowerCamelCase	(						__A    :							int		,		__A    :							Optional[Any]		,		__A    :							int )      ->					int:
    # Initialise PyTorch model
    _UpperCAmelCase				:      Dict			  =				RemBertConfig.from_json_file(__A )
    print('''Building PyTorch model from configuration: {}'''.format(str(__A ) ) )
    _UpperCAmelCase				:      int			  =				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__":
  SCREAMING_SNAKE_CASE 							=						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.'
  )
  SCREAMING_SNAKE_CASE 							=						parser.parse_args()
  convert_rembert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.rembert_config_file, args.pytorch_dump_path)




