


def 			_a  (				SCREAMING_SNAKE_CASE	:				int    , SCREAMING_SNAKE_CASE	:				bool = False     ):







	"""simple docstring"""



	if n == 2:
		return True
	if not n % 2 or n < 2:
		return False
	if n > 5 and n % 10 not in (1, 3, 7, 9):  # can quickly check last digit
		return False
	if n > 3317044064679887385961981 and not allow_probable:
		raise ValueError(
		    '''Warning: upper bound of deterministic test is exceeded. '''
		    '''Pass allow_probable=True to allow probabilistic test. '''
		    '''A return value of True indicates a probable prime.'''     )
	# array bounds provided by analysis
	UpperCamelCase__					:    List[str]          =   [
	    2047,
	    1373653,
	    25326001,
	    3215031751,
	    2152302898747,
	    3474749660383,
	    341550071728321,
	    1,
	    3825123056546413051,
	    1,
	    1,
	    318665857834031151167461,
	    3317044064679887385961981,
	]

	UpperCamelCase__					:    str          =   [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41]
	for idx, _p in enumerate(UpperCAmelCase__    , 1     ):
		if n < _p:
			# then we have our last prime to check
			UpperCamelCase__					:    Any          =   primes[:idx]
			break
	UpperCamelCase__					:    str          =   n - 1, 0
	# break up n -1 into a power of 2 (s) and
	# remaining odd component
	# essentially, solve for d * 2 ** s == n - 1
	while d % 2 == 0:
		d //= 2
		s += 1
	for prime in plist:
		UpperCamelCase__					:    Optional[int]          =   False
		for r in range(UpperCAmelCase__     ):
			UpperCamelCase__					:    Any          =   pow(UpperCAmelCase__    , d * 2**r    , UpperCAmelCase__     )
			# see article for analysis explanation for m
			if (r == 0 and m == 1) or ((m + 1) % n == 0):
				UpperCamelCase__					:    List[Any]          =   True
				# this loop will not determine compositeness
				break
		if pr:
			continue
		# if pr is False, then the above loop never evaluated to true,
		# and the n MUST be composite
		return False
	return True

def 			_a  (				):







	"""simple docstring"""



	assert not miller_rabin(561     )
	assert miller_rabin(563     )
	# 2047

	assert not miller_rabin(838201     )
	assert miller_rabin(838207     )
	# 1_373_653

	assert not miller_rabin(17316001     )
	assert miller_rabin(17316017     )
	# 25_326_001

	assert not miller_rabin(3078386641     )
	assert miller_rabin(3078386653     )
	# 3_215_031_751

	assert not miller_rabin(1713045574801     )
	assert miller_rabin(1713045574819     )
	# 2_152_302_898_747

	assert not miller_rabin(2779799728307     )
	assert miller_rabin(2779799728327     )
	# 3_474_749_660_383

	assert not miller_rabin(113850023909441     )
	assert miller_rabin(113850023909527     )
	# 341_550_071_728_321

	assert not miller_rabin(1275041018848804351     )
	assert miller_rabin(1275041018848804391     )
	# 3_825_123_056_546_413_051

	assert not miller_rabin(79666464458507787791867     )
	assert miller_rabin(79666464458507787791951     )
	# 318_665_857_834_031_151_167_461

	assert not miller_rabin(552840677446647897660333     )
	assert miller_rabin(552840677446647897660359     )
	# 3_317_044_064_679_887_385_961_981
	# upper limit for probabilistic test


if __name__ == "__main__":
							test_miller_rabin()






import contextlib
import importlib
import io
import unittest

import transformers

# Try to import everything from transformers to ensure every object can be loaded.
from transformers import *  # noqa F406
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, require_tf, require_torch
from transformers.utils import ContextManagers, find_labels, is_flax_available, is_tf_available, is_torch_available


if is_torch_available():
       from transformers import BertForPreTraining, BertForQuestionAnswering, BertForSequenceClassification

if is_tf_available():
       from transformers import TFBertForPreTraining, TFBertForQuestionAnswering, TFBertForSequenceClassification

if is_flax_available():
       from transformers import FlaxBertForPreTraining, FlaxBertForQuestionAnswering, FlaxBertForSequenceClassification


__UpperCamelCase       :       Dict						       =				DUMMY_UNKNOWN_IDENTIFIER
# An actual model hosted on huggingface.co

__UpperCamelCase       :       Optional[int]						       =				"main"
# Default branch name
__UpperCamelCase       :       Optional[Any]						       =				"f2c752cfc5c0ab6f4bdec59acea69eefbee381c2"
# One particular commit (not the top of `main`)
__UpperCamelCase       :       str						       =				"aaaaaaa"
# This commit does not exist, so we should 404.

__UpperCamelCase       :       Optional[Any]						       =				"d9e9f15bc825e4b2c9249e9578f884bbcb5e3684"
# Sha-1 of config.json on the top of `main`, for checking purposes
__UpperCamelCase       :       Tuple						       =				"4b243c475af8d0a7754e87d7d096c92e5199ec2fe168a2ee7998e3b8e9bcb1d3"

@contextlib.contextmanager
def 			_a  (				):







 """simple docstring"""



 print('''Welcome!'''     )
 yield
 print('''Bye!'''     )

@contextlib.contextmanager
def 			_a  (				):







 """simple docstring"""



 print('''Bonjour!'''     )
 yield
 print('''Au revoir!'''     )

class       __magic_name__	(     unittest.TestCase):


     def      UpperCAmelCase__	(      self							:     Union[str, Any]			)  ->      Any:





      '''simple docstring'''






      assert transformers.__spec__ is not None
      assert importlib.util.find_spec('''transformers'''			) is not None



class       __magic_name__	(     unittest.TestCase):


     @unittest.mock.patch('''sys.stdout'''							,	new_callable=io.StringIO			)
     def      UpperCAmelCase__	(      self							:     Union[str, Any]							,	lowerCamelCase__							:     Union[str, Any]			)  ->      Optional[Any]:





      '''simple docstring'''






      with ContextManagers([]			):
       print('''Transformers are awesome!'''			)
      # The print statement adds a new line at the end of the output
      self.assertEqual(mock_stdout.getvalue()							,	'''Transformers are awesome!\n'''			)


     @unittest.mock.patch('''sys.stdout'''							,	new_callable=io.StringIO			)
     def      UpperCAmelCase__	(      self							:     Any							,	lowerCamelCase__							:     Union[str, Any]			)  ->      Dict:





      '''simple docstring'''






      with ContextManagers([context_en()]			):
       print('''Transformers are awesome!'''			)
      # The output should be wrapped with an English welcome and goodbye
      self.assertEqual(mock_stdout.getvalue()							,	'''Welcome!\nTransformers are awesome!\nBye!\n'''			)


     @unittest.mock.patch('''sys.stdout'''							,	new_callable=io.StringIO			)
     def      UpperCAmelCase__	(      self							:     List[Any]							,	lowerCamelCase__							:     List[str]			)  ->      Tuple:





      '''simple docstring'''






      with ContextManagers([context_fr(), context_en()]			):
       print('''Transformers are awesome!'''			)
      # The output should be wrapped with an English and French welcome and goodbye
      self.assertEqual(mock_stdout.getvalue()							,	'''Bonjour!\nWelcome!\nTransformers are awesome!\nBye!\nAu revoir!\n'''			)


     @require_torch
     def      UpperCAmelCase__	(      self							:     Tuple			)  ->      Optional[int]:





      '''simple docstring'''






      self.assertEqual(find_labels(lowerCamelCase__			)							,	['''labels''']			)
      self.assertEqual(find_labels(lowerCamelCase__			)							,	['''labels''', '''next_sentence_label''']			)
      self.assertEqual(find_labels(lowerCamelCase__			)							,	['''start_positions''', '''end_positions''']			)

      class       __magic_name__	(     __lowerCAmelCase):
           pass



      self.assertEqual(find_labels(lowerCamelCase__			)							,	['''labels''']			)


     @require_tf
     def      UpperCAmelCase__	(      self							:     Union[str, Any]			)  ->      Tuple:





      '''simple docstring'''






      self.assertEqual(find_labels(lowerCamelCase__			)							,	['''labels''']			)
      self.assertEqual(find_labels(lowerCamelCase__			)							,	['''labels''', '''next_sentence_label''']			)
      self.assertEqual(find_labels(lowerCamelCase__			)							,	['''start_positions''', '''end_positions''']			)

      class       __magic_name__	(     __lowerCAmelCase):
           pass



      self.assertEqual(find_labels(lowerCamelCase__			)							,	['''labels''']			)


     @require_flax
     def      UpperCAmelCase__	(      self							:     str			)  ->      Optional[Any]:





      '''simple docstring'''






      self.assertEqual(find_labels(lowerCamelCase__			)							,	[]			)
      self.assertEqual(find_labels(lowerCamelCase__			)							,	[]			)
      self.assertEqual(find_labels(lowerCamelCase__			)							,	[]			)

      class       __magic_name__	(     __lowerCAmelCase):
           pass



      self.assertEqual(find_labels(lowerCamelCase__			)							,	[]			)


