





import argparse

from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird
from transformers.utils import logging


logging.set_verbosity_info()



def 		A_    (					_lowerCAmelCase							,       _lowerCAmelCase							,       _lowerCAmelCase							,       _lowerCAmelCase					)						->			Any:
 # Initialise PyTorch model
 UpperCamelCase     : Any	     =       BigBirdConfig.from_json_file(_lowerCAmelCase					)
 print(F"""Building PyTorch model from configuration: {config}"""					)

 if is_trivia_qa:
  UpperCamelCase     : Union[str, Any]	     =       BigBirdForQuestionAnswering(_lowerCAmelCase					)
 else:
  UpperCamelCase     : Optional[int]	     =       BigBirdForPreTraining(_lowerCAmelCase					)

 # Load weights from tf checkpoint
 load_tf_weights_in_big_bird(_lowerCAmelCase							,       _lowerCAmelCase							,       is_trivia_qa=_lowerCAmelCase					)

 # Save pytorch-model
 print(F"""Save PyTorch model to {pytorch_dump_path}"""					)
 model.save_pretrained(_lowerCAmelCase					)


if __name__ == "__main__":
    __lowerCamelCase	:					Dict			  =					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(
        """--big_bird_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."""
    )
    parser.add_argument(
        """--is_trivia_qa""", action="""store_true""", help="""Whether to convert a model with a trivia_qa head."""
    )
    __lowerCamelCase	:					List[str]			  =					parser.parse_args()
    convert_tf_checkpoint_to_pytorch(
        args.tf_checkpoint_path, args.big_bird_config_file, args.pytorch_dump_path, args.is_trivia_qa
    )







def 		A_    (					_lowerCAmelCase = "The quick brown fox jumps over the lazy dog"							,       )						->			bool:
 UpperCamelCase     : Union[str, Any]	     =       set()

 # Replace all the whitespace in our sentence
 UpperCamelCase     : Union[str, Any]	     =       input_str.replace(" "							,       ""					)
 for alpha in input_str:
  if "a" <= alpha.lower() <= "z":
   frequency.add(alpha.lower()					)
 return len(_lowerCAmelCase					) == 26



def 		A_    (					_lowerCAmelCase = "The quick brown fox jumps over the lazy dog"							,       )						->			bool:
 UpperCamelCase     : List[Any]	     =       [False] * 26
 for char in input_str:
  if char.islower():
   UpperCamelCase     : Tuple	     =       True
  elif char.isupper():
   UpperCamelCase     : str	     =       True
 return all(_lowerCAmelCase					)



def 		A_    (					_lowerCAmelCase = "The quick brown fox jumps over the lazy dog"							,       )						->			bool:
 return len({char for char in input_str.lower() if char.isalpha()}					) == 26



def 		A_    (					)						->			None:
 from timeit import timeit

 UpperCamelCase     : Tuple	     =       "from __main__ import is_pangram, is_pangram_faster, is_pangram_fastest"
 print(timeit("is_pangram()"							,       setup=_lowerCAmelCase					)					)
 print(timeit("is_pangram_faster()"							,       setup=_lowerCAmelCase					)					)
 print(timeit("is_pangram_fastest()"							,       setup=_lowerCAmelCase					)					)
 # 5.348480500048026, 2.6477354579837993, 1.8470395830227062
 # 5.036091582966037, 2.644472333951853,  1.8869528750656173


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    benchmark()
