




import os
from datetime import datetime as dt

from github import Github


lowerCAmelCase_						=			[
    'good first issue',
    'feature request',
    'wip',
]






def  snake_case(    )			->							int:





					'''simple docstring'''


					lowercase :       List[Any]       =			Github(os.environ['''GITHUB_TOKEN''']   )
					lowercase :       Optional[int]       =			g.get_repo('''huggingface/accelerate'''   )
					lowercase :       Union[str, Any]       =			repo.get_issues(state='''open'''   )

					for issue in open_issues:
										lowercase :       Optional[int]       =			sorted([comment for comment in issue.get_comments()]			,		key=lambda __magic_name__   : i.created_at			,		reverse=__magic_name__   )
										lowercase :       str       =			comments[0] if len(__magic_name__   ) > 0 else None
										lowercase :       Tuple       =			dt.utcnow()
										lowercase :       List[Any]       =			(current_time - issue.updated_at).days
										lowercase :       List[Any]       =			(current_time - issue.created_at).days
										if (
										    last_comment is not None
										    and last_comment.user.login == "github-actions[bot]"
										    and days_since_updated > 7
										    and days_since_creation >= 30
										    and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()   )
										):
															# Close issue since it has been 7 days of inactivity since bot mention.
															issue.edit(state='''closed'''   )
										elif (
										    days_since_updated > 23
										    and days_since_creation >= 30
										    and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()   )
										):
															# Add stale comment
															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/accelerate/blob/main/CONTRIBUTING.md) '''
															    '''are likely to be ignored.'''   )


if __name__ == "__main__":
	main()





import os
import sys
import unittest


lowerCAmelCase_						=			os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
sys.path.append(os.path.join(git_repo_path, 'utils'))

import check_dummies  # noqa: E402
from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init  # noqa: E402


# Align TRANSFORMERS_PATH in check_dummies with the current path
lowerCAmelCase_						=			os.path.join(git_repo_path, 'src', 'diffusers')
class 						_A (  unittest.TestCase				):






  def  __a      (  self		:     Any				)		->   str:






       """simple docstring"""







       lowercase :       List[str]       =			find_backend('''    if not is_torch_available():'''				)
       self.assertEqual(_A				,						'''torch'''				)

       # backend_with_underscore = find_backend("    if not is_tensorflow_text_available():")
       # self.assertEqual(backend_with_underscore, "tensorflow_text")

       lowercase :       str       =			find_backend('''    if not (is_torch_available() and is_transformers_available()):'''				)
       self.assertEqual(_A				,						'''torch_and_transformers'''				)

       # double_backend_with_underscore = find_backend(
       #    "    if not (is_sentencepiece_available() and is_tensorflow_text_available()):"
       # )
       # self.assertEqual(double_backend_with_underscore, "sentencepiece_and_tensorflow_text")

       lowercase :       str       =			find_backend(
           '''    if not (is_torch_available() and is_transformers_available() and is_onnx_available()):'''				)
       self.assertEqual(_A				,						'''torch_and_transformers_and_onnx'''				)






  def  __a      (  self		:     Optional[int]				)		->   Any:






       """simple docstring"""







       lowercase :       Dict       =			read_init()
       # We don't assert on the exact list of keys to allow for smooth grow of backend-specific objects
       self.assertIn('''torch'''				,						_A				)
       self.assertIn('''torch_and_transformers'''				,						_A				)
       self.assertIn('''flax_and_transformers'''				,						_A				)
       self.assertIn('''torch_and_transformers_and_onnx'''				,						_A				)

       # Likewise, we can't assert on the exact content of a key
       self.assertIn('''UNet2DModel'''				,						objects['''torch''']				)
       self.assertIn('''FlaxUNet2DConditionModel'''				,						objects['''flax''']				)
       self.assertIn('''StableDiffusionPipeline'''				,						objects['''torch_and_transformers''']				)
       self.assertIn('''FlaxStableDiffusionPipeline'''				,						objects['''flax_and_transformers''']				)
       self.assertIn('''LMSDiscreteScheduler'''				,						objects['''torch_and_scipy''']				)
       self.assertIn('''OnnxStableDiffusionPipeline'''				,						objects['''torch_and_transformers_and_onnx''']				)






  def  __a      (  self		:     Union[str, Any]				)		->   str:






       """simple docstring"""







       lowercase :       List[str]       =			create_dummy_object('''CONSTANT'''				,						'''\'torch\''''				)
       self.assertEqual(_A				,						'''\nCONSTANT = None\n'''				)

       lowercase :       List[Any]       =			create_dummy_object('''function'''				,						'''\'torch\''''				)
       self.assertEqual(
           _A				,						'''\ndef function(*args, **kwargs):\n    requires_backends(function, \'torch\')\n'''				)

       lowercase :       Tuple       =			'''
class FakeClass(metaclass=DummyObject):
    _backends = \'torch\'

    def __init__(self, *args, **kwargs):
        requires_backends(self, \'torch\')

    @classmethod
    def from_config(cls, *args, **kwargs):
        requires_backends(cls, \'torch\')

    @classmethod
    def from_pretrained(cls, *args, **kwargs):
        requires_backends(cls, \'torch\')
'''
       lowercase :       List[Any]       =			create_dummy_object('''FakeClass'''				,						'''\'torch\''''				)
       self.assertEqual(_A				,						_A				)






  def  __a      (  self		:     Union[str, Any]				)		->   str:






       """simple docstring"""







       lowercase :       Optional[int]       =			'''# This file is autogenerated by the command `make fix-copies`, do not edit.
from ..utils import DummyObject, requires_backends


CONSTANT = None


def function(*args, **kwargs):
    requires_backends(function, ["torch"])


class FakeClass(metaclass=DummyObject):
    _backends = ["torch"]

    def __init__(self, *args, **kwargs):
        requires_backends(self, ["torch"])

    @classmethod
    def from_config(cls, *args, **kwargs):
        requires_backends(cls, ["torch"])

    @classmethod
    def from_pretrained(cls, *args, **kwargs):
        requires_backends(cls, ["torch"])
'''
       lowercase :       int       =			create_dummy_files({'''torch''': ['''CONSTANT''', '''function''', '''FakeClass''']}				)
       self.assertEqual(dummy_files['''torch''']				,						_A				)