





from __future__ import annotations

import os
from typing import Any

import requests

UpperCamelCase__  			='''https://api.github.com'''

# https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user
UpperCamelCase__  			=BASE_URL + '''/user'''

# https://github.com/settings/tokens
UpperCamelCase__  			=os.environ.get('USER_TOKEN', '')






def      lowerCamelCase__      (__lowerCamelCase						):
     _SCREAMING_SNAKE_CASE							:						int         =				{
         '''Authorization''': f"""token {auth_token}""",
         '''Accept''': '''application/vnd.github.v3+json''',
     }
     return requests.get(UpperCAmelCase_,							headers=UpperCAmelCase_						).json()


if __name__ == "__main__":  # pragma: no cover
       if USER_TOKEN:
              for key, value in fetch_github_info(USER_TOKEN).items():
                     print(f"{key}: {value}")
       else:
              raise ValueError('\'USER_TOKEN\' field cannot be empty.')



import unittest

import numpy as np

from transformers import DistilBertConfig, 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.numpy as jnp

     from transformers.models.distilbert.modeling_flax_distilbert import (
         FlaxDistilBertForMaskedLM,
         FlaxDistilBertForMultipleChoice,
         FlaxDistilBertForQuestionAnswering,
         FlaxDistilBertForSequenceClassification,
         FlaxDistilBertForTokenClassification,
         FlaxDistilBertModel,
     )







class 						_snake_case    ( unittest.TestCase				):




 def __init__(						self   ,    _lowerCamelCase   ,    _lowerCamelCase=13   ,    _lowerCamelCase=7   ,    _lowerCamelCase=True   ,    _lowerCamelCase=True   ,    _lowerCamelCase=True   ,    _lowerCamelCase=True   ,    _lowerCamelCase=99   ,    _lowerCamelCase=32   ,    _lowerCamelCase=5   ,    _lowerCamelCase=4   ,    _lowerCamelCase=37   ,    _lowerCamelCase="gelu"   ,    _lowerCamelCase=0.1   ,    _lowerCamelCase=0.1   ,    _lowerCamelCase=512   ,    _lowerCamelCase=16   ,    _lowerCamelCase=2   ,    _lowerCamelCase=0.02   ,    _lowerCamelCase=4   ,    ):
       a		:Optional[Any]									=			parent
       a		:str									=			batch_size
       a		:Tuple									=			seq_length
       a		:List[Any]									=			is_training
       a		:Optional[int]									=			use_attention_mask
       a		:List[str]									=			use_token_type_ids
       a		:str									=			use_labels
       a		:Optional[Any]									=			vocab_size
       a		:Optional[int]									=			hidden_size
       a		:Tuple									=			num_hidden_layers
       a		:Union[str, Any]									=			num_attention_heads
       a		:int									=			intermediate_size
       a		:int									=			hidden_act
       a		:int									=			hidden_dropout_prob
       a		:Union[str, Any]									=			attention_probs_dropout_prob
       a		:str									=			max_position_embeddings
       a		:Dict									=			type_vocab_size
       a		:str									=			type_sequence_label_size
       a		:List[str]									=			initializer_range
       a		:Optional[Any]									=			num_choices




 def 			SCREAMING_SNAKE_CASE__							(						self       ):
       a		:Tuple									=			ids_tensor([self.batch_size, self.seq_length]   ,    self.vocab_size       )

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

       a		:Any									=			DistilBertConfig(
           vocab_size=self.vocab_size   ,    dim=self.hidden_size   ,    n_layers=self.num_hidden_layers   ,    n_heads=self.num_attention_heads   ,    hidden_dim=self.intermediate_size   ,    hidden_act=self.hidden_act   ,    dropout=self.hidden_dropout_prob   ,    attention_dropout=self.attention_probs_dropout_prob   ,    max_position_embeddings=self.max_position_embeddings   ,    initializer_range=self.initializer_range   ,    tie_weights_=_lowerCamelCase   ,    )

       return config, input_ids, attention_mask




 def 			SCREAMING_SNAKE_CASE__							(						self       ):
       a		:List[str]									=			self.prepare_config_and_inputs()
       a				,							a				,							a		:str									=			config_and_inputs
       a		:List[Any]									=			{'''input_ids''': input_ids, '''attention_mask''': attention_mask}
       return config, inputs_dict







@require_flax
class 						_snake_case    ( _snake_case		,       unittest.TestCase				):
 SCREAMING_SNAKE_CASE__ =			(
     (
         FlaxDistilBertModel,
         FlaxDistilBertForMaskedLM,
         FlaxDistilBertForMultipleChoice,
         FlaxDistilBertForQuestionAnswering,
         FlaxDistilBertForSequenceClassification,
         FlaxDistilBertForTokenClassification,
         FlaxDistilBertForQuestionAnswering,
     )
     if is_flax_available()
     else ()
 )




 def 			SCREAMING_SNAKE_CASE__							(						self       ):
       a		:List[Any]									=			FlaxDistilBertModelTester(self       )




 @slow
 def 			SCREAMING_SNAKE_CASE__							(						self       ):
       for model_class_name in self.all_model_classes:
             a		:int									=			model_class_name.from_pretrained('''distilbert-base-uncased'''       )
             a		:List[str]									=			model(np.ones((1, 1)       )       )
             self.assertIsNotNone(_lowerCamelCase       )







@require_flax
class 						_snake_case    ( unittest.TestCase				):




 @slow
 def 			SCREAMING_SNAKE_CASE__							(						self       ):
       a		:List[str]									=			FlaxDistilBertModel.from_pretrained('''distilbert-base-uncased'''       )
       a		:Optional[Any]									=			np.array([[0, 345, 232, 328, 740, 140, 1695, 69, 6078, 1588, 2]]       )
       a		:List[Any]									=			np.array([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]       )
       a		:List[str]									=			model(_lowerCamelCase   ,    attention_mask=_lowerCamelCase       )[0]
       a		:Union[str, Any]									=			(1, 11, 768)
       self.assertEqual(output.shape   ,    _lowerCamelCase       )
       a		:int									=			np.array([[[-0.1639, 0.3299, 0.1648], [-0.1746, 0.3289, 0.1710], [-0.1884, 0.3357, 0.1810]]]       )

       self.assertTrue(jnp.allclose(output[:, 1:4, 1:4]   ,    _lowerCamelCase   ,    atol=1e-4       )       )





