



from datetime import datetime as dt
import os

from github import Github


A__  :  List[str]								=					[
    '''good first issue''',
    '''good second issue''',
    '''good difficult issue''',
    '''feature request''',
    '''new model''',
    '''wip''',
]


def 			UpperCamelCase(  ):
		lowerCAmelCase_			:     Union[str, Any]									= Github(os.environ['''GITHUB_TOKEN'''] )
		lowerCAmelCase_			:     Tuple									= g.get_repo('''huggingface/transformers''' )
		lowerCAmelCase_			:     int									= repo.get_issues(state='''open''' )

		for issue in open_issues:
				lowerCAmelCase_			:     Optional[Any]									= sorted([comment for comment in issue.get_comments()]     ,key=lambda __UpperCamelCase : i.created_at     ,reverse=__UpperCamelCase )
				lowerCAmelCase_			:     Tuple									= comments[0] if len(__UpperCamelCase ) > 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() )
				):
						# print(f"Would close issue {issue.number} since it has been 7 days of inactivity since bot mention.")
						issue.edit(state='''closed''' )
				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() )
				):
						# print(f"Would add stale comment to {issue.number}")
						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/transformers/blob/main/CONTRIBUTING.md) '''
						    '''are likely to be ignored.''' )


if __name__ == "__main__":
						main()










import gc
import unittest

from diffusers import FlaxStableDiffusionInpaintPipeline
from diffusers.utils import is_flax_available, load_image, slow
from diffusers.utils.testing_utils import require_flax


if is_flax_available():
						import jax
						import jax.numpy as jnp
						from flax.jax_utils import replicate
						from flax.training.common_utils import shard



@slow
@require_flax
class 				__snake_case						(     unittest.TestCase						):




							def    UpperCAmelCase__			(       self     :       Tuple):
									# clean up the VRAM after each test
									super().tearDown()
									gc.collect()







							def    UpperCAmelCase__			(       self     :       List[str]):
									lowerCAmelCase_			:     Any									= load_image(
									    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
									    '''/sd2-inpaint/init_image.png''')
									lowerCAmelCase_			:     str									= load_image(
									    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-inpaint/mask.png''')

									lowerCAmelCase_			:     List[Any]									= '''xvjiarui/stable-diffusion-2-inpainting'''
									lowerCAmelCase_					,  lowerCAmelCase_			:     Optional[Any]									= FlaxStableDiffusionInpaintPipeline.from_pretrained(A_				,				safety_checker=A_)

									lowerCAmelCase_			:     List[str]									= '''Face of a yellow cat, high resolution, sitting on a park bench'''

									lowerCAmelCase_			:     List[Any]									= jax.random.PRNGKey(0)
									lowerCAmelCase_			:     str									= 5_0

									lowerCAmelCase_			:     List[Any]									= jax.device_count()
									lowerCAmelCase_			:     Union[str, Any]									= num_samples * [prompt]
									lowerCAmelCase_			:     str									= num_samples * [init_image]
									lowerCAmelCase_			:     Union[str, Any]									= num_samples * [mask_image]
									lowerCAmelCase_					,  lowerCAmelCase_					,  lowerCAmelCase_			:     Optional[Any]									= pipeline.prepare_inputs(A_				,				A_				,				A_)

									# shard inputs and rng
									lowerCAmelCase_			:     str									= replicate(A_)
									lowerCAmelCase_			:     str									= jax.random.split(A_				,				jax.device_count())
									lowerCAmelCase_			:     List[Any]									= shard(A_)
									lowerCAmelCase_			:     str									= shard(A_)
									lowerCAmelCase_			:     Tuple									= shard(A_)

									lowerCAmelCase_			:     int									= pipeline(
									    A_				,				A_				,				A_				,				A_				,				A_				,				A_				,				jit=A_)

									lowerCAmelCase_			:     Optional[int]									= output.images.reshape(A_				,				5_1_2				,				5_1_2				,				3)

									lowerCAmelCase_			:     List[str]									= images[0, 2_5_3:2_5_6, 2_5_3:2_5_6, -1]

									lowerCAmelCase_			:     int									= jnp.asarray(jax.device_get(image_slice.flatten()))
									lowerCAmelCase_			:     str									= jnp.array(
									    [0.361_1307, 0.3764_9736, 0.375_7408, 0.3821_3953, 0.3929_5167, 0.384_1631, 0.4155_4978, 0.413_7475, 0.421_7084])
									print(F"""output_slice: {output_slice}""")
									assert jnp.abs(output_slice - expected_slice).max() < 1e-2





