


'''simple docstring'''



import unittest

import numpy as np

from transformers.file_utils import is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
		import torch

if is_vision_available():
		from PIL import Image

		from transformers import DPTImageProcessor


class 						_snake_case   (       unittest.TestCase		):




					def __init__( self							,							_lowerCamelCase							,							_lowerCamelCase=7							,							_lowerCamelCase=3							,							_lowerCamelCase=18							,							_lowerCamelCase=30							,							_lowerCamelCase=400							,							_lowerCamelCase=True							,							_lowerCamelCase=None							,							_lowerCamelCase=True							,							_lowerCamelCase=[0.5, 0.5, 0.5]							,							_lowerCamelCase=[0.5, 0.5, 0.5]							,							):
								UpperCAmelCase__					:   Tuple       				=       size if size is not None else {"""height""": 18, """width""": 18}
								UpperCAmelCase__					:   Union[str, Any]       				=       parent
								UpperCAmelCase__					:   Any       				=       batch_size
								UpperCAmelCase__					:   str       				=       num_channels
								UpperCAmelCase__					:   List[str]       				=       image_size
								UpperCAmelCase__					:   Tuple       				=       min_resolution
								UpperCAmelCase__					:   Any       				=       max_resolution
								UpperCAmelCase__					:   int       				=       do_resize
								UpperCAmelCase__					:   Any       				=       size
								UpperCAmelCase__					:   Optional[int]       				=       do_normalize
								UpperCAmelCase__					:   Any       				=       image_mean
								UpperCAmelCase__					:   int       				=       image_std




					def 			snake_case__  ( self):
								return {
								    "image_mean": self.image_mean,
								    "image_std": self.image_std,
								    "do_normalize": self.do_normalize,
								    "do_resize": self.do_resize,
								    "size": self.size,
								}


@require_torch
@require_vision
class 						_snake_case   (       a__    ,				unittest.TestCase		):
					lowerCAmelCase :int						=   DPTImageProcessor if is_vision_available() else None




					def 			snake_case__  ( self):
								UpperCAmelCase__					:   Dict       				=       DPTImageProcessingTester(self)




					@property
					def 			snake_case__  ( self):
								return self.image_processor_tester.prepare_image_processor_dict()




					def 			snake_case__  ( self):
								UpperCAmelCase__					:   int       				=       self.image_processing_class(**self.image_processor_dict)
								self.assertTrue(hasattr(_lowerCamelCase							,							"""image_mean"""))
								self.assertTrue(hasattr(_lowerCamelCase							,							"""image_std"""))
								self.assertTrue(hasattr(_lowerCamelCase							,							"""do_normalize"""))
								self.assertTrue(hasattr(_lowerCamelCase							,							"""do_resize"""))
								self.assertTrue(hasattr(_lowerCamelCase							,							"""size"""))




					def 			snake_case__  ( self):
								UpperCAmelCase__					:   int       				=       self.image_processing_class.from_dict(self.image_processor_dict)
								self.assertEqual(image_processor.size							,							{"""height""": 18, """width""": 18})

								UpperCAmelCase__					:   int       				=       self.image_processing_class.from_dict(self.image_processor_dict							,							size=42)
								self.assertEqual(image_processor.size							,							{"""height""": 42, """width""": 42})




					def 			snake_case__  ( self):
								# Initialize image_processing
								UpperCAmelCase__					:   Tuple       				=       self.image_processing_class(**self.image_processor_dict)
								# create random PIL images
								UpperCAmelCase__					:   List[str]       				=       prepare_image_inputs(self.image_processor_tester							,							equal_resolution=_lowerCamelCase)
								for image in image_inputs:
											self.assertIsInstance(_lowerCamelCase							,							Image.Image)

								# Test not batched input
								UpperCAmelCase__					:   str       				=       image_processing(image_inputs[0]							,							return_tensors="""pt""").pixel_values
								self.assertEqual(
								    encoded_images.shape							,							(
								        1,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.size["""height"""],
								        self.image_processor_tester.size["""width"""],
								    )							,							)

								# Test batched
								UpperCAmelCase__					:   Dict       				=       image_processing(_lowerCamelCase							,							return_tensors="""pt""").pixel_values
								self.assertEqual(
								    encoded_images.shape							,							(
								        self.image_processor_tester.batch_size,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.size["""height"""],
								        self.image_processor_tester.size["""width"""],
								    )							,							)




					def 			snake_case__  ( self):
								# Initialize image_processing
								UpperCAmelCase__					:   List[Any]       				=       self.image_processing_class(**self.image_processor_dict)
								# create random numpy tensors
								UpperCAmelCase__					:   Tuple       				=       prepare_image_inputs(self.image_processor_tester							,							equal_resolution=_lowerCamelCase							,							numpify=_lowerCamelCase)
								for image in image_inputs:
											self.assertIsInstance(_lowerCamelCase							,							np.ndarray)

								# Test not batched input
								UpperCAmelCase__					:   Optional[Any]       				=       image_processing(image_inputs[0]							,							return_tensors="""pt""").pixel_values
								self.assertEqual(
								    encoded_images.shape							,							(
								        1,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.size["""height"""],
								        self.image_processor_tester.size["""width"""],
								    )							,							)

								# Test batched
								UpperCAmelCase__					:   Tuple       				=       image_processing(_lowerCamelCase							,							return_tensors="""pt""").pixel_values
								self.assertEqual(
								    encoded_images.shape							,							(
								        self.image_processor_tester.batch_size,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.size["""height"""],
								        self.image_processor_tester.size["""width"""],
								    )							,							)




					def 			snake_case__  ( self):
								# Initialize image_processing
								UpperCAmelCase__					:   Tuple       				=       self.image_processing_class(**self.image_processor_dict)
								# create random PyTorch tensors
								UpperCAmelCase__					:   Tuple       				=       prepare_image_inputs(self.image_processor_tester							,							equal_resolution=_lowerCamelCase							,							torchify=_lowerCamelCase)
								for image in image_inputs:
											self.assertIsInstance(_lowerCamelCase							,							torch.Tensor)

								# Test not batched input
								UpperCAmelCase__					:   Any       				=       image_processing(image_inputs[0]							,							return_tensors="""pt""").pixel_values
								self.assertEqual(
								    encoded_images.shape							,							(
								        1,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.size["""height"""],
								        self.image_processor_tester.size["""width"""],
								    )							,							)

								# Test batched
								UpperCAmelCase__					:   Optional[Any]       				=       image_processing(_lowerCamelCase							,							return_tensors="""pt""").pixel_values
								self.assertEqual(
								    encoded_images.shape							,							(
								        self.image_processor_tester.batch_size,
								        self.image_processor_tester.num_channels,
								        self.image_processor_tester.size["""height"""],
								        self.image_processor_tester.size["""width"""],
								    )							,							)



'''simple docstring'''



import os
from datetime import datetime as dt

from github import Github


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







def       _UpperCamelCase (						):
			UpperCAmelCase__					:   Union[str, Any]       				=       Github(os.environ["""GITHUB_TOKEN"""]   )
			UpperCAmelCase__					:   Any       				=       g.get_repo("""huggingface/diffusers"""   )
			UpperCAmelCase__					:   Optional[int]       				=       repo.get_issues(state="""open"""   )

			for issue in open_issues:
						UpperCAmelCase__					:   Any       				=       sorted(issue.get_comments()	, key=lambda UpperCamelCase__   : i.created_at	, reverse=UpperCamelCase__   )
						UpperCAmelCase__					:   List[Any]       				=       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 >= 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()