

"""simple docstring"""




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   __lowercase      (     unittest.TestCase       ):

  def __init__(	self		:      Union[str, Any]       ,A		:      Optional[int]       ,A		:      int=13       ,A		:      Tuple=7       ,A		:      Dict=True       ,A		:      Optional[int]=True       ,A		:      Tuple=True       ,A		:      str=True       ,A		:      Any=99       ,A		:      Tuple=32       ,A		:      Dict=5       ,A		:      Optional[int]=4       ,A		:      Dict=37       ,A		:      Any="gelu"       ,A		:      Any=0.1       ,A		:      Optional[int]=0.1       ,A		:      Union[str, Any]=512       ,A		:      Any=16       ,A		:      List[str]=2       ,A		:      List[Any]=0.0_2       ,A		:      Optional[int]=4       ,):






   '''simple docstring'''
   UpperCAmelCase__       :	Dict        =       parent
   UpperCAmelCase__       :	Any        =       batch_size
   UpperCAmelCase__       :	List[Any]        =       seq_length
   UpperCAmelCase__       :	Optional[int]        =       is_training
   UpperCAmelCase__       :	Optional[Any]        =       use_attention_mask
   UpperCAmelCase__       :	int        =       use_token_type_ids
   UpperCAmelCase__       :	int        =       use_labels
   UpperCAmelCase__       :	Any        =       vocab_size
   UpperCAmelCase__       :	Union[str, Any]        =       hidden_size
   UpperCAmelCase__       :	int        =       num_hidden_layers
   UpperCAmelCase__       :	int        =       num_attention_heads
   UpperCAmelCase__       :	Dict        =       intermediate_size
   UpperCAmelCase__       :	Any        =       hidden_act
   UpperCAmelCase__       :	Union[str, Any]        =       hidden_dropout_prob
   UpperCAmelCase__       :	Any        =       attention_probs_dropout_prob
   UpperCAmelCase__       :	str        =       max_position_embeddings
   UpperCAmelCase__       :	List[Any]        =       type_vocab_size
   UpperCAmelCase__       :	List[str]        =       type_sequence_label_size
   UpperCAmelCase__       :	List[Any]        =       initializer_range
   UpperCAmelCase__       :	List[Any]        =       num_choices

  def  __lowercase							(	self		:      Optional[Any]     ):






   '''simple docstring'''
   UpperCAmelCase__       :	List[str]        =       ids_tensor([self.batch_size, self.seq_length]       ,self.vocab_size     )

   UpperCAmelCase__       :	List[str]        =       None
   if self.use_attention_mask:
    UpperCAmelCase__       :	str        =       random_attention_mask([self.batch_size, self.seq_length]     )

   UpperCAmelCase__       :	int        =       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_=A       ,)

   return config, input_ids, attention_mask




  def  __lowercase							(	self		:      List[Any]     ):






   '''simple docstring'''
   UpperCAmelCase__       :	Optional[Any]        =       self.prepare_config_and_inputs()
   UpperCAmelCase__ ,   UpperCAmelCase__ ,   UpperCAmelCase__       :	Any        =       config_and_inputs
   UpperCAmelCase__       :	str        =       {"""input_ids""": input_ids, """attention_mask""": attention_mask}
   return config, inputs_dict







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

  def  __lowercase							(	self		:      Optional[int]     ):






   '''simple docstring'''
   UpperCAmelCase__       :	List[str]        =       FlaxDistilBertModelTester(self     )




  @slow
  def  __lowercase							(	self		:      Optional[Any]     ):






   '''simple docstring'''
   for model_class_name in self.all_model_classes:
    UpperCAmelCase__       :	Union[str, Any]        =       model_class_name.from_pretrained("""distilbert-base-uncased"""     )
    UpperCAmelCase__       :	List[Any]        =       model(np.ones((1, 1)     )     )
    self.assertIsNotNone(A     )







@require_flax
class   __lowercase      (     unittest.TestCase       ):

  @slow
  def  __lowercase							(	self		:      Union[str, Any]     ):






   '''simple docstring'''
   UpperCAmelCase__       :	Union[str, Any]        =       FlaxDistilBertModel.from_pretrained("""distilbert-base-uncased"""     )
   UpperCAmelCase__       :	List[Any]        =       np.array([[0, 345, 232, 328, 740, 140, 1_695, 69, 6_078, 1_588, 2]]     )
   UpperCAmelCase__       :	str        =       np.array([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]     )
   UpperCAmelCase__       :	Dict        =       model(A       ,attention_mask=A     )[0]
   UpperCAmelCase__       :	List[Any]        =       (1, 11, 768)
   self.assertEqual(output.shape       ,A     )
   UpperCAmelCase__       :	Any        =       np.array([[[-0.1_6_3_9, 0.3_2_9_9, 0.1_6_4_8], [-0.1_7_4_6, 0.3_2_8_9, 0.1_7_1_0], [-0.1_8_8_4, 0.3_3_5_7, 0.1_8_1_0]]]     )

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









import os
from datetime import datetime as dt

from github import Github


lowerCamelCase__							:						int							     =   [
    """good first issue""",
    """good second issue""",
    """good difficult issue""",
    """enhancement""",
    """new pipeline/model""",
    """new scheduler""",
    """wip""",
]







def SCREAMING_SNAKE_CASE	(			)    ->				Optional[Any]:
  snake_case__						= Github(os.environ['''GITHUB_TOKEN''']				)
  snake_case__						= g.get_repo('''huggingface/diffusers'''				)
  snake_case__						= repo.get_issues(state='''open'''				)

  for issue in open_issues:
    snake_case__						= sorted(issue.get_comments()							,   key=lambda __lowerCAmelCase				: i.created_at							,   reverse=__lowerCAmelCase				)
    snake_case__						= comments[0] if len(__lowerCAmelCase				) > 0 else None
    if (
        last_comment is not None
        and last_comment.user.login == "github-actions[bot]"
        and (dt.utcnow() - issue.updated_at).days > 7
        and (dt.utcnow() - issue.created_at).days >= 30
        and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()				)
    ):
      # Closes the issue after 7 days of inactivity since the Stalebot notification.
      issue.edit(state='''closed'''				)
    elif (
        "stale" in issue.get_labels()
        and last_comment is not None
        and last_comment.user.login != "github-actions[bot]"
    ):
      # Opens the issue if someone other than Stalebot commented.
      issue.edit(state='''open'''				)
      issue.remove_from_labels('''stale'''				)
    elif (
        (dt.utcnow() - issue.updated_at).days > 23
        and (dt.utcnow() - issue.created_at).days >= 30
        and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()				)
    ):
      # Post a Stalebot notification after 23 days of inactivity.
      issue.create_comment(
          '''This issue has been automatically marked as stale because it has not had '''
          '''recent activity. If you think this still needs to be addressed '''
          '''please comment on this thread.\n\nPlease note that issues that do not follow the '''
          '''[contributing guidelines](https://github.com/huggingface/diffusers/blob/main/CONTRIBUTING.md) '''
          '''are likely to be ignored.'''				)
      issue.add_to_labels('''stale'''				)


if __name__ == "__main__":
   main()

