





import argparse

import torch

from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert
from transformers.utils import logging


logging.set_verbosity_info()



def 		A_    (					_lowerCAmelCase							,       _lowerCAmelCase							,       _lowerCAmelCase					)						->			Tuple:
 # Initialise PyTorch model
 UpperCamelCase     : Tuple	     =       BertConfig.from_json_file(_lowerCAmelCase					)
 print(F"""Building PyTorch model from configuration: {config}"""					)
 UpperCamelCase     : Union[str, Any]	     =       BertForPreTraining(_lowerCAmelCase					)

 # Load weights from tf checkpoint
 load_tf_weights_in_bert(_lowerCAmelCase							,       _lowerCAmelCase							,       _lowerCAmelCase					)

 # Save pytorch-model
 print(F"""Save PyTorch model to {pytorch_dump_path}"""					)
 torch.save(model.state_dict()							,       _lowerCAmelCase					)


if __name__ == "__main__":
    SCREAMING_SNAKE_CASE_	:					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(
        """--bert_config_file""",
        default=None,
        type=str,
        required=True,
        help=(
            """The config json file corresponding to the pre-trained BERT 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_	:					Dict			  =					parser.parse_args()
    convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.bert_config_file, args.pytorch_dump_path)







class  A__       :  # Public class to implement a graph





      def __init__(			self	,							A_	,							A_	,							A_       ):
       '''simple docstring'''




       UpperCamelCase     : Optional[int]	     =       row
       UpperCamelCase     : Any	     =       col
       UpperCamelCase     : Optional[Any]	     =       graph





      def 	__UpperCamelCase(			self	,							A_	,							A_	,							A_       ):
       '''simple docstring'''




       return (
           0 <= i < self.ROW
           and 0 <= j < self.COL
           and not visited[i][j]
           and self.graph[i][j]
       )





      def 	__UpperCamelCase(			self	,							A_	,							A_	,							A_       ):
       '''simple docstring'''




       UpperCamelCase     : Any	     =       [-1, -1, -1, 0, 0, 1, 1, 1]  # Coordinate order
       UpperCamelCase     : Dict	     =       [-1, 0, 1, -1, 1, -1, 0, 1]
       UpperCamelCase     : Any	     =       True  # Make those cells visited
       for k in range(8       ):
        if self.is_safe(i + row_nbr[k]	,							j + col_nbr[k]	,							A_       ):
         self.diffs(i + row_nbr[k]	,							j + col_nbr[k]	,							A_       )





      def 	__UpperCamelCase(			self       ):  # And finally, count all islands.
       '''simple docstring'''




       UpperCamelCase     : str	     =       [[False for j in range(self.COL       )] for i in range(self.ROW       )]
       UpperCamelCase     : int	     =       0
       for i in range(self.ROW       ):
        for j in range(self.COL       ):
         if visited[i][j] is False and self.graph[i][j] == 1:
          self.diffs(A_	,							A_	,							A_       )
          count += 1
       return count
