'''simple docstring'''





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


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

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

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


@contextlib.contextmanager
def     __lowerCAmelCase						(       )      ->	Optional[int]:





     '''simple docstring'''





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


@contextlib.contextmanager
def     __lowerCAmelCase						(       )      ->	int:





     '''simple docstring'''





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






class 				UpperCAmelCase (       unittest.TestCase ):




    '''simple docstring'''







    def       _UpperCamelCase    (       self )							-> str:
         # If the spec is missing, importlib would not be able to import the module dynamically.
         assert transformers.__spec__ is not None
         assert importlib.util.find_spec('transformers' ) is not None






class 				UpperCAmelCase (       unittest.TestCase ):




    '''simple docstring'''







    @unittest.mock.patch('sys.stdout'    ,							new_callable=io.StringIO )
    def       _UpperCamelCase    (       self    ,							lowercase__ )							-> str:
         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    ,							lowercase__ )							-> Any:
         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    ,							lowercase__ )							-> Union[str, Any]:
         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 )							-> Optional[int]:
         self.assertEqual(find_labels(lowercase__ )    ,							['labels'] )
         self.assertEqual(find_labels(lowercase__ )    ,							['labels', 'next_sentence_label'] )
         self.assertEqual(find_labels(lowercase__ )    ,							['start_positions', 'end_positions'] )






         class 				UpperCAmelCase (       _SCREAMING_SNAKE_CASE ):




             '''simple docstring'''







             pass






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






    @require_tf
    def       _UpperCamelCase    (       self )							-> str:
         self.assertEqual(find_labels(lowercase__ )    ,							['labels'] )
         self.assertEqual(find_labels(lowercase__ )    ,							['labels', 'next_sentence_label'] )
         self.assertEqual(find_labels(lowercase__ )    ,							['start_positions', 'end_positions'] )






         class 				UpperCAmelCase (       _SCREAMING_SNAKE_CASE ):




             '''simple docstring'''







             pass






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






    @require_flax
    def       _UpperCamelCase    (       self )							-> Any:
         # Flax models don't have labels
         self.assertEqual(find_labels(lowercase__ )    ,							[] )
         self.assertEqual(find_labels(lowercase__ )    ,							[] )
         self.assertEqual(find_labels(lowercase__ )    ,							[] )






         class 				UpperCAmelCase (       _SCREAMING_SNAKE_CASE ):




             '''simple docstring'''







             pass






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




'''simple docstring'''





def     __lowerCAmelCase						(       a_       ,      a_		)      ->	str:





     '''simple docstring'''





     if number < 0 or shift_amount < 0:
          raise ValueError('both inputs must be positive integers'		)

     SCREAMING_SNAKE_CASE					:			str    	=       str(bin(a_		)		)
     binary_number += "0" * shift_amount
     return binary_number


def     __lowerCAmelCase						(       a_       ,      a_		)      ->	str:





     '''simple docstring'''





     if number < 0 or shift_amount < 0:
          raise ValueError('both inputs must be positive integers'		)

     SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       str(bin(a_		)		)[2:]
     if shift_amount >= len(a_		):
          return "0b0"
     SCREAMING_SNAKE_CASE					:			Dict    	=       binary_number[: len(a_		) - shift_amount]
     return "0b" + shifted_binary_number


def     __lowerCAmelCase						(       a_       ,      a_		)      ->	str:





     '''simple docstring'''





     if number >= 0:  # Get binary representation of positive number
          SCREAMING_SNAKE_CASE					:			Tuple    	=       '0' + str(bin(a_		)		).strip('-'		)[2:]
     else:  # Get binary (2's complement) representation of negative number
          SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       len(bin(a_		)[3:]		)  # Find 2's complement of number
          SCREAMING_SNAKE_CASE					:			Any    	=       bin(abs(a_		) - (1 << binary_number_length)		)[3:]
          SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       (
              '1' + '0' * (binary_number_length - len(a_		)) + binary_number
          )

     if shift_amount >= len(a_		):
          return "0b" + binary_number[0] * len(a_		)
     return (
         "0b"
         + binary_number[0] * shift_amount
         + binary_number[: len(a_		) - shift_amount]
     )


if __name__ == "__main__":
 import doctest

 doctest.testmod()



