






from timeit import timeit

__lowerCamelCase	:		Optional[Any]										=   {
    """MALAYALAM""": True,
    """String""": False,
    """rotor""": True,
    """level""": True,
    """A""": True,
    """BB""": True,
    """ABC""": False,
    """amanaplanacanalpanama""": True,  # "a man a plan a canal panama"
}
# Ensure our test data is valid
assert all((key == key[::-1]) is value for key, value in test_data.items())







def 			A__							(      _a  :					str	):





 '''simple docstring'''







 snake_case__  :    Optional[int]							       =0
 snake_case__  :    Optional[int]							       =len(_a	) - 1
 while start_i < end_i:
  if s[start_i] == s[end_i]:
   start_i += 1
   end_i -= 1
  else:
   return False
 return True







def 			A__							(      _a  :					str	):





 '''simple docstring'''







 snake_case__  :    Optional[int]							       =len(_a	) // 2
 snake_case__  :    Optional[Any]							       =len(_a	)

 # We need to traverse till half of the length of string
 # as we can get access of the i'th last element from
 # i'th index.
 # eg: [0,1,2,3,4,5] => 4th index can be accessed
 # with the help of 1st index (i==n-i-1)
 # where n is length of string
 return all(s[i] == s[n - i - 1] for i in range(_a	)	)







def 			A__							(      _a  :					str	):





 '''simple docstring'''







 if len(_a	) <= 2:
  return True
 if s[0] == s[len(_a	) - 1]:
  return is_palindrome_recursive(s[1:-1]	)
 else:
  return False







def 			A__							(      _a  :					str	):





 '''simple docstring'''







 return s == s[::-1]







def 			A__							(      _a  :					str	):





 '''simple docstring'''







 snake_case__  :    Union[str, Any]							       =f"all({name}(key) is value for key, value in test_data.items())"
 snake_case__  :    Optional[int]							       =f"from __main__ import test_data, {name}"
 snake_case__  :    int							       =500000
 snake_case__  :    Tuple							       =timeit(stmt=_a		,  setup=_a		,  number=_a	)
 print(f"{name:<35} finished {number:,} runs in {result:.5f} seconds"	)


if __name__ == "__main__":
       for key, value in test_data.items():
              assert is_palindrome(key) is is_palindrome_recursive(key)
              assert is_palindrome(key) is is_palindrome_slice(key)
              print(F"{key:21} {value}")
       print("""a man a plan a canal panama""")

       # finished 500,000 runs in 0.46793 seconds
       benchmark_function("""is_palindrome_slice""")
       # finished 500,000 runs in 0.85234 seconds
       benchmark_function("""is_palindrome""")
       # finished 500,000 runs in 1.32028 seconds
       benchmark_function("""is_palindrome_recursive""")
       # finished 500,000 runs in 2.08679 seconds
       benchmark_function("""is_palindrome_traversal""")













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__							(      _a  :					int		,  _a  :					Any		,  _a  :					Union[str, Any]		,  _a  :					Tuple	):





 '''simple docstring'''







 snake_case__  :    Any							       =BigBirdConfig.from_json_file(_a	)
 print(f"Building PyTorch model from configuration: {config}"	)

 if is_trivia_qa:
  snake_case__  :    str							       =BigBirdForQuestionAnswering(_a	)
 else:
  snake_case__  :    Optional[int]							       =BigBirdForPreTraining(_a	)

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

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


if __name__ == "__main__":
       __lowerCamelCase	:		Union[str, Any]										=   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	:		Tuple										=   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
       )





