


'''simple docstring'''






import unittest

from transformers import BigBirdConfig, is_flax_available
from transformers.testing_utils import require_flax, slow

from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask


if is_flax_available():
		import jax

		from transformers.models.big_bird.modeling_flax_big_bird import (
		    FlaxBigBirdForCausalLM,
		    FlaxBigBirdForMaskedLM,
		    FlaxBigBirdForMultipleChoice,
		    FlaxBigBirdForPreTraining,
		    FlaxBigBirdForQuestionAnswering,
		    FlaxBigBirdForSequenceClassification,
		    FlaxBigBirdForTokenClassification,
		    FlaxBigBirdModel,
		)




class 		a__    (							unittest.TestCase  ):





							'''simple docstring'''






							def __init__(		self ,   lowerCamelCase_ ,   lowerCamelCase_=2 ,   lowerCamelCase_=56 ,   lowerCamelCase_=True ,   lowerCamelCase_=True ,   lowerCamelCase_=True ,   lowerCamelCase_=True ,   lowerCamelCase_=99 ,   lowerCamelCase_=32 ,   lowerCamelCase_=2 ,   lowerCamelCase_=2 ,   lowerCamelCase_=7 ,   lowerCamelCase_="gelu_new" ,   lowerCamelCase_=0.1 ,   lowerCamelCase_=0.1 ,   lowerCamelCase_=5_12 ,   lowerCamelCase_=16 ,   lowerCamelCase_=2 ,   lowerCamelCase_=0.02 ,   lowerCamelCase_=4 ,   lowerCamelCase_="block_sparse" ,   lowerCamelCase_=True ,   lowerCamelCase_=False ,   lowerCamelCase_=2 ,   lowerCamelCase_=3 ,   )	->							Tuple:
														lowerCAmelCase__	       =     parent
														lowerCAmelCase__	       =     batch_size
														lowerCAmelCase__	       =     seq_length
														lowerCAmelCase__	       =     is_training
														lowerCAmelCase__	       =     use_attention_mask
														lowerCAmelCase__	       =     use_token_type_ids
														lowerCAmelCase__	       =     use_labels
														lowerCAmelCase__	       =     vocab_size
														lowerCAmelCase__	       =     hidden_size
														lowerCAmelCase__	       =     num_hidden_layers
														lowerCAmelCase__	       =     num_attention_heads
														lowerCAmelCase__	       =     intermediate_size
														lowerCAmelCase__	       =     hidden_act
														lowerCAmelCase__	       =     hidden_dropout_prob
														lowerCAmelCase__	       =     attention_probs_dropout_prob
														lowerCAmelCase__	       =     max_position_embeddings
														lowerCAmelCase__	       =     type_vocab_size
														lowerCAmelCase__	       =     type_sequence_label_size
														lowerCAmelCase__	       =     initializer_range
														lowerCAmelCase__	       =     num_choices

														lowerCAmelCase__	       =     rescale_embeddings
														lowerCAmelCase__	       =     attention_type
														lowerCAmelCase__	       =     use_bias
														lowerCAmelCase__	       =     block_size
														lowerCAmelCase__	       =     num_random_blocks







							def   __SCREAMING_SNAKE_CASE							(		self       )	->							Dict:
														lowerCAmelCase__	       =     ids_tensor([self.batch_size, self.seq_length] ,   self.vocab_size       )

														lowerCAmelCase__	       =     None
														if self.use_attention_mask:
																					lowerCAmelCase__	       =     random_attention_mask([self.batch_size, self.seq_length]       )

														lowerCAmelCase__	       =     None
														if self.use_token_type_ids:
																					lowerCAmelCase__	       =     ids_tensor([self.batch_size, self.seq_length] ,   self.type_vocab_size       )

														lowerCAmelCase__	       =     BigBirdConfig(
														    vocab_size=self.vocab_size ,   hidden_size=self.hidden_size ,   num_hidden_layers=self.num_hidden_layers ,   num_attention_heads=self.num_attention_heads ,   intermediate_size=self.intermediate_size ,   hidden_act=self.hidden_act ,   hidden_dropout_prob=self.hidden_dropout_prob ,   attention_probs_dropout_prob=self.attention_probs_dropout_prob ,   max_position_embeddings=self.max_position_embeddings ,   type_vocab_size=self.type_vocab_size ,   is_decoder=lowerCamelCase_ ,   initializer_range=self.initializer_range ,   attention_type=self.attention_type ,   block_size=self.block_size ,   num_random_blocks=self.num_random_blocks ,   use_bias=self.use_bias ,   rescale_embeddings=self.rescale_embeddings ,   )

														return config, input_ids, token_type_ids, attention_mask







							def   __SCREAMING_SNAKE_CASE							(		self       )	->							Any:
														lowerCAmelCase__	       =     self.prepare_config_and_inputs()
														lowerCAmelCase__       , lowerCAmelCase__       , lowerCAmelCase__       , lowerCAmelCase__	       =     config_and_inputs
														lowerCAmelCase__	       =     {
														    '''input_ids''': input_ids,
														    '''token_type_ids''': token_type_ids,
														    '''attention_mask''': attention_mask,
														}
														return config, inputs_dict




@require_flax
class 		a__    (							a__    ,    unittest.TestCase  ):





							'''simple docstring'''






							lowercase__      :       Optional[int]     						=				(
							    (
							        FlaxBigBirdForCausalLM,
							        FlaxBigBirdModel,
							        FlaxBigBirdForPreTraining,
							        FlaxBigBirdForMaskedLM,
							        FlaxBigBirdForMultipleChoice,
							        FlaxBigBirdForQuestionAnswering,
							        FlaxBigBirdForSequenceClassification,
							        FlaxBigBirdForTokenClassification,
							    )
							    if is_flax_available()
							    else ()
							)

							lowercase__      :       Union[str, Any]     						=				False
							lowercase__      :       Optional[int]     						=				False







							def   __SCREAMING_SNAKE_CASE							(		self       )	->							Any:
														lowerCAmelCase__	       =     FlaxBigBirdModelTester(self       )







							@slow
							# copied from `test_modeling_flax_common` because it takes much longer than other models
							def   __SCREAMING_SNAKE_CASE							(		self       )	->							Optional[Any]:
														super().test_from_pretrained_save_pretrained()







							@slow
							# copied from `test_modeling_flax_common` because it takes much longer than other models
							def   __SCREAMING_SNAKE_CASE							(		self       )	->							List[Any]:
														super().test_from_pretrained_with_no_automatic_init()







							@slow
							# copied from `test_modeling_flax_common` because it takes much longer than other models
							def   __SCREAMING_SNAKE_CASE							(		self       )	->							Dict:
														super().test_no_automatic_init()







							@slow
							# copied from `test_modeling_flax_common` because it takes much longer than other models
							def   __SCREAMING_SNAKE_CASE							(		self       )	->							Dict:
														super().test_hidden_states_output()







							@slow
							def   __SCREAMING_SNAKE_CASE							(		self       )	->							int:
														for model_class_name in self.all_model_classes:
																					lowerCAmelCase__	       =     model_class_name.from_pretrained('''google/bigbird-roberta-base'''       )
																					self.assertIsNotNone(lowerCamelCase_       )







							def   __SCREAMING_SNAKE_CASE							(		self       )	->							List[str]:
														if self.test_attn_probs:
																					super().test_attention_outputs()







							@slow
							# copied from `test_modeling_flax_common` because it takes much longer than other models
							def   __SCREAMING_SNAKE_CASE							(		self       )	->							str:
														lowerCAmelCase__       , lowerCAmelCase__	       =     self.model_tester.prepare_config_and_inputs_for_common()

														for model_class in self.all_model_classes:
																					with self.subTest(model_class.__name__       ):
																												lowerCAmelCase__	       =     self._prepare_for_class(lowerCamelCase_ ,   lowerCamelCase_       )
																												lowerCAmelCase__	       =     model_class(lowerCamelCase_       )

																												@jax.jit
																												def model_jitted(lowerCamelCase_ ,   lowerCamelCase_=None ,   **lowerCamelCase_       ):
																																			return model(input_ids=lowerCamelCase_ ,   attention_mask=lowerCamelCase_ ,   **lowerCamelCase_       )

																												with self.subTest('''JIT Enabled'''       ):
																																			lowerCAmelCase__	       =     model_jitted(**lowerCamelCase_       ).to_tuple()

																												with self.subTest('''JIT Disabled'''       ):
																																			with jax.disable_jit():
																																										lowerCAmelCase__	       =     model_jitted(**lowerCamelCase_       ).to_tuple()

																												self.assertEqual(len(lowerCamelCase_       ) ,   len(lowerCamelCase_       )       )
																												for jitted_output, output in zip(lowerCamelCase_ ,   lowerCamelCase_       ):
																																			self.assertEqual(jitted_output.shape ,   output.shape       )







							def   __SCREAMING_SNAKE_CASE							(		self ,   lowerCamelCase_ ,   lowerCamelCase_ ,   lowerCamelCase_ ,   lowerCamelCase_=1e-5 ,   lowerCamelCase_="outputs" ,   lowerCamelCase_=None       )	->							str:
														# `bigbird_block_sparse_attention` in `FlaxBigBird` returns `attention_probs = None`, while in PyTorch version,
														# an effort was done to return `attention_probs` (yet to be verified).
														if name.startswith('''outputs.attentions'''       ):
																					return
														else:
																					super().check_pt_flax_outputs(lowerCamelCase_ ,   lowerCamelCase_ ,   lowerCamelCase_ ,   lowerCamelCase_ ,   lowerCamelCase_ ,   lowerCamelCase_       )



'''simple docstring'''






import argparse
import json
import subprocess


def  _snake_case       (					A			,   A	)						->   Tuple:
							lowerCAmelCase__	       =     []

							lowerCAmelCase__	       =     (
							    F"""curl -H \"Accept: application/vnd.github+json\" -H \"Authorization: Bearer {token}\""""
							    ''' https://api.github.com/repos/huggingface/transformers/actions/runners'''
							)
							lowerCAmelCase__	       =     subprocess.run(A			,   shell=A			,   stdout=subprocess.PIPE	)
							lowerCAmelCase__	       =     output.stdout.decode('''utf-8'''	)
							lowerCAmelCase__	       =     json.loads(A	)

							lowerCAmelCase__	       =     status['''runners''']
							for runner in runners:
														if runner["name"] in target_runners:
																					if runner["status"] == "offline":
																												offline_runners.append(A	)

    # save the result so we can report them on Slack
							with open('''offline_runners.txt'''			,   '''w'''	) as fp:
														fp.write(json.dumps(A	)	)

							if len(A	) > 0:
														lowerCAmelCase__	       =     '''\n'''.join([x['''name'''] for x in offline_runners]	)
														raise ValueError(F"""The following runners are offline:\n{failed}"""	)


if __name__ == "__main__":


		def  _snake_case       (					A	)						->   Optional[Any]:
									return values.split(''','''	)

		__UpperCAmelCase       =							argparse.ArgumentParser()
		# Required parameters
		parser.add_argument(
		    '''--target_runners''',
		    default=None,
		    type=list_str,
		    required=True,
		    help='''Comma-separated list of runners to check status.''',
		)

		parser.add_argument(
		    '''--token''', default=None, type=str, required=True, help='''A token that has actions:read permission.'''
		)
		__UpperCAmelCase       =							parser.parse_args()






		get_runner_status(args.target_runners, args.token)