






'''simple docstring'''





import os
from datetime import datetime as dt

from github import Github


_UpperCamelCase						:						List[str]  =					[
    'good first issue',
    'good second issue',
    'good difficult issue',
    'enhancement',
    'new pipeline/model',
    'new scheduler',
    'wip',
]
def __UpperCAmelCase   (					)    ->   List[Any]:
			UpperCAmelCase_      :       int          =       Github(os.environ['''GITHUB_TOKEN''']		)
			UpperCAmelCase_      :       List[Any]          =       g.get_repo('''huggingface/diffusers'''		)
			UpperCAmelCase_      :       Union[str, Any]          =       repo.get_issues(state='''open'''		)

			for issue in open_issues:
						UpperCAmelCase_      :       Optional[int]          =       sorted(issue.get_comments()			,       key=lambda A		: i.created_at			,       reverse=A		)
						UpperCAmelCase_      :       Any          =       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 >= 3_0
						    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 > 2_3
						    and (dt.utcnow() - issue.created_at).days >= 3_0
						    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()










'''simple docstring'''





import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
						import torch

						from transformers.generation import DisjunctiveConstraint


@require_torch
class  snake_case__      (					unittest.TestCase):




					def 		A      (  self  :		Union[str, Any]      )    ->							List[str]:
								# For consistency across different places the DisjunctiveConstraint is called,
								# dc.token_ids is a list of integers. It is also initialized only by integers.

								UpperCAmelCase_      :       Union[str, Any]          =       [[1, 2, 4], [1, 2, 3, 4]]
								UpperCAmelCase_      :       Dict          =       DisjunctiveConstraint(_A      )
								self.assertTrue(isinstance(dc.token_ids				, _A      )      )

								with self.assertRaises(_A      ):
											DisjunctiveConstraint(torch.LongTensor([[1, 2, 4], [1, 2, 3]]      )      )

								with self.assertRaises(_A      ):
											DisjunctiveConstraint([torch.LongTensor([1, 2, 4]      ), torch.LongTensor([1, 2, 3, 4, 5]      )]      )




					def 		A      (  self  :		Optional[int]      )    ->							List[Any]:
								# We can't have constraints that are complete subsets of another. This leads to a preverse
								# interpretation of "constraint fulfillment": does generating [1,2,3] fulfill the constraint?
								# It would mean that it generated [1,2] which fulfills it, but it's in the middle of potentially
								# fulfilling [1,2,3,4]. If we believe that [1,2,3] does fulfill the constraint, then the algorithm
								# will necessarily never reach [1,2,3,4], giving users a false sense of control (better to just not allow it).
								UpperCAmelCase_      :       Optional[Any]          =       [[1, 2], [1, 2, 3, 4]]

								with self.assertRaises(_A      ):
											DisjunctiveConstraint(_A      )  # fails here




					def 		A      (  self  :		List[str]      )    ->							int:
								UpperCAmelCase_      :       Dict          =       [[1, 2, 3], [1, 2, 4]]

								UpperCAmelCase_      :       List[Any]          =       DisjunctiveConstraint(_A      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       List[str]          =       dc.update(1      )
								UpperCAmelCase_      :       int          =       stepped is True and completed is False and reset is False
								self.assertTrue(_A      )
								self.assertTrue(not dc.completed      )
								self.assertTrue(dc.current_seq == [1]      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       Tuple          =       dc.update(2      )
								UpperCAmelCase_      :       Optional[int]          =       stepped is True and completed is False and reset is False
								self.assertTrue(_A      )
								self.assertTrue(not dc.completed      )
								self.assertTrue(dc.current_seq == [1, 2]      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       Any          =       dc.update(3      )
								UpperCAmelCase_      :       List[Any]          =       stepped is True and completed is True and reset is False
								self.assertTrue(_A      )
								self.assertTrue(dc.completed      )  # Completed!
								self.assertTrue(dc.current_seq == [1, 2, 3]      )





					def 		A      (  self  :		List[Any]      )    ->							Any:
								UpperCAmelCase_      :       int          =       [[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

								UpperCAmelCase_      :       str          =       DisjunctiveConstraint(_A      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       Tuple          =       dc.update(1      )
								self.assertTrue(not dc.completed      )
								self.assertTrue(dc.current_seq == [1]      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       str          =       dc.update(2      )
								self.assertTrue(not dc.completed      )
								self.assertTrue(dc.current_seq == [1, 2]      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       str          =       dc.update(4      )
								self.assertTrue(not dc.completed      )
								self.assertTrue(dc.current_seq == [1, 2, 4]      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       Any          =       dc.update(5      )
								self.assertTrue(dc.completed      )  # Completed!
								self.assertTrue(dc.current_seq == [1, 2, 4, 5]      )

								dc.reset()

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       List[str]          =       dc.update(1      )
								self.assertTrue(not dc.completed      )
								self.assertTrue(dc.remaining() == 3      )
								self.assertTrue(dc.current_seq == [1]      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       Optional[int]          =       dc.update(2      )
								self.assertTrue(not dc.completed      )
								self.assertTrue(dc.remaining() == 2      )
								self.assertTrue(dc.current_seq == [1, 2]      )

								UpperCAmelCase_    ,      UpperCAmelCase_    ,      UpperCAmelCase_      :       int          =       dc.update(5      )
								self.assertTrue(dc.completed      )  # Completed!
								self.assertTrue(dc.remaining() == 0      )
								self.assertTrue(dc.current_seq == [1, 2, 5]      )


