



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):







							'''simple docstring'''






							def __init__(							self  ,  a_  ,  a_=13  ,  a_=7  ,  a_=True  ,  a_=True  ,  a_=True  ,  a_=True  ,  a_=99  ,  a_=32  ,  a_=5  ,  a_=4  ,  a_=37  ,  a_="gelu"  ,  a_=0.1  ,  a_=0.1  ,  a_=512  ,  a_=16  ,  a_=2  ,  a_=0.02  ,  a_=4  ,  ):
											a__				      =		parent
											a__				      =		batch_size
											a__				      =		seq_length
											a__				      =		is_training
											a__				      =		use_attention_mask
											a__				      =		use_token_type_ids
											a__				      =		use_labels
											a__				      =		vocab_size
											a__				      =		hidden_size
											a__				      =		num_hidden_layers
											a__				      =		num_attention_heads
											a__				      =		intermediate_size
											a__				      =		hidden_act
											a__				      =		hidden_dropout_prob
											a__				      =		attention_probs_dropout_prob
											a__				      =		max_position_embeddings
											a__				      =		type_vocab_size
											a__				      =		type_sequence_label_size
											a__				      =		initializer_range
											a__				      =		num_choices


							def _a      (							self		):
											a__				      =		ids_tensor([self.batch_size, self.seq_length]  ,  self.vocab_size		)

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

											a__				      =		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 _a      (							self		):
											a__				      =		self.prepare_config_and_inputs()
											a__      ,			a__      ,			a__				      =		config_and_inputs
											a__				      =		{"""input_ids""": input_ids, """attention_mask""": attention_mask}
											return config, inputs_dict




@require_flax
class  __snake_case      (   SCREAMING_SNAKE_CASE			,unittest.TestCase):







							'''simple docstring'''






							UpperCamelCase__				:      Tuple         =					(
							    (
							        FlaxDistilBertModel,
							        FlaxDistilBertForMaskedLM,
							        FlaxDistilBertForMultipleChoice,
							        FlaxDistilBertForQuestionAnswering,
							        FlaxDistilBertForSequenceClassification,
							        FlaxDistilBertForTokenClassification,
							        FlaxDistilBertForQuestionAnswering,
							    )
							    if is_flax_available()
							    else ()
							)


							def _a      (							self		):
											a__				      =		FlaxDistilBertModelTester(self		)







							@slow
							def _a      (							self		):
											for model_class_name in self.all_model_classes:
															a__				      =		model_class_name.from_pretrained("""distilbert-base-uncased"""		)
															a__				      =		model(np.ones((1, 1)		)		)
															self.assertIsNotNone(a_		)




@require_flax
class  __snake_case      (   unittest.TestCase):







							'''simple docstring'''






							@slow
							def _a      (							self		):
											a__				      =		FlaxDistilBertModel.from_pretrained("""distilbert-base-uncased"""		)
											a__				      =		np.array([[0, 345, 232, 328, 740, 140, 1_695, 69, 6_078, 1_588, 2]]		)
											a__				      =		np.array([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]		)
											a__				      =		model(a_  ,  attention_mask=a_		)[0]
											a__				      =		(1, 11, 768)
											self.assertEqual(output.shape  ,  a_		)
											a__				      =		np.array([[[-0.1_639, 0.3_299, 0.1_648], [-0.1_746, 0.3_289, 0.1_710], [-0.1_884, 0.3_357, 0.1_810]]]		)

											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


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

def 			A_      (	):

				"""simple docstring"""
				a__				      =		Github(os.environ["""GITHUB_TOKEN"""]		)
				a__				      =		g.get_repo("""huggingface/diffusers"""		)
				a__				      =		repo.get_issues(state="""open"""		)

				for issue in open_issues:
								a__				      =		sorted(issue.get_comments() ,		key=lambda __a		: i.created_at ,		reverse=__a		)
								a__				      =		comments[0] if len(__a		) > 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()

