
'''simple docstring'''

# tests directory-specific settings - this file is run automatically
# by pytest before any tests are run

import doctest
import sys
import warnings
from os.path import abspath, dirname, join

import _pytest

from transformers.testing_utils import HfDoctestModule, HfDocTestParser


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
UpperCAmelCase__ :			str											=		abspath(join(dirname(__file__), "src"))
sys.path.insert(1, git_repo_path)

# silence FutureWarning warnings in tests since often we can't act on them until
# they become normal warnings - i.e. the tests still need to test the current functionality
warnings.simplefilter(action="ignore", category=FutureWarning)







def 	A  (   UpperCamelCase_       :  Any   )       ->							List[str]:







			'''simple docstring'''



			config.addinivalue_line(
			    "markers"    ,						"is_pt_tf_cross_test: mark test to run only when PT and TF interactions are tested"   )
			config.addinivalue_line(
			    "markers"    ,						"is_pt_flax_cross_test: mark test to run only when PT and FLAX interactions are tested"   )
			config.addinivalue_line("markers"    ,						"is_pipeline_test: mark test to run only when pipelines are tested"   )
			config.addinivalue_line("markers"    ,						"is_staging_test: mark test to run only in the staging environment"   )
			config.addinivalue_line("markers"    ,						"accelerate_tests: mark test that require accelerate"   )
			config.addinivalue_line("markers"    ,						"tool_tests: mark the tool tests that are run on their specific schedule"   )







def 	A  (   UpperCamelCase_       :  List[str]   )       ->							Any:







			'''simple docstring'''



			from transformers.testing_utils import pytest_addoption_shared

			pytest_addoption_shared(UpperCamelCase_   )







def 	A  (   UpperCamelCase_       :  int   )       ->							Union[str, Any]:







			'''simple docstring'''



			from transformers.testing_utils import pytest_terminal_summary_main

			lowerCAmelCase__										=				terminalreporter.config.getoption("--make-reports"   )
			if make_reports:
						pytest_terminal_summary_main(UpperCamelCase_    ,						id=UpperCamelCase_   )







def 	A  (   UpperCamelCase_       :  int    ,						UpperCamelCase_       :  Any   )       ->							Optional[int]:







			'''simple docstring'''



			if exitstatus == 5:
						lowerCAmelCase__										=				0


# Doctest custom flag to ignore output.
UpperCAmelCase__ :			List[str]											=		doctest.register_optionflag("IGNORE_RESULT")

UpperCAmelCase__ :			Optional[Any]											=		doctest.OutputChecker






class  A  (						SCREAMING_SNAKE_CASE__     ):





	def 				__SCREAMING_SNAKE_CASE	(       self      :							List[str]   ,				__magic_name__      :							Dict   ,				__magic_name__      :							Optional[int]   ,				__magic_name__      :							Tuple				):


				"""simple docstring"""

				if IGNORE_RESULT & optionflags:
							return True
				return OutputChecker.check_output(self   ,				__magic_name__   ,				__magic_name__   ,				__magic_name__				)

UpperCAmelCase__ :			Any											=		CustomOutputChecker
UpperCAmelCase__ :			str											=		HfDoctestModule



UpperCAmelCase__ :			Optional[int]											=		HfDocTestParser









from timeit import timeit

lowerCamelCase		   =			{
    '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_ (       SCREAMING_SNAKE_CASE__   : str	):
       '''simple docstring'''





       _lowerCamelCase			:						Optional[int]            =0
       _lowerCamelCase			:						Union[str, Any]            =len(SCREAMING_SNAKE_CASE__	) - 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_ (       SCREAMING_SNAKE_CASE__   : str	):
       '''simple docstring'''





       _lowerCamelCase			:						List[str]            =len(SCREAMING_SNAKE_CASE__	) // 2
       _lowerCamelCase			:						Optional[Any]            =len(SCREAMING_SNAKE_CASE__	)

       # 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(SCREAMING_SNAKE_CASE__	)	)




def       a_ (       SCREAMING_SNAKE_CASE__   : str	):
       '''simple docstring'''





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




def       a_ (       SCREAMING_SNAKE_CASE__   : str	):
       '''simple docstring'''





       return s == s[::-1]




def       a_ (       SCREAMING_SNAKE_CASE__   : str	):
       '''simple docstring'''





       _lowerCamelCase			:						Optional[int]            =F'''all({name}(key) is value for key, value in test_data.items())'''
       _lowerCamelCase			:						List[Any]            =F'''from __main__ import test_data, {name}'''
       _lowerCamelCase			:						Any            =500_000
       _lowerCamelCase			:						Dict            =timeit(stmt=SCREAMING_SNAKE_CASE__						,     setup=SCREAMING_SNAKE_CASE__						,     number=SCREAMING_SNAKE_CASE__	)
       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')


