






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_   ()				->						Optional[Any]:



					"""simple docstring"""
					__a					:						Union[str, Any]      =					Github(os.environ["GITHUB_TOKEN"]      )
					__a					:						List[Any]      =					g.get_repo("huggingface/diffusers"      )
					__a					:						List[Any]      =					repo.get_issues(state="open"      )

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













from __future__ import annotations

import unittest

import numpy as np

from transformers import BlipTextConfig
from transformers.testing_utils import require_tf, slow
from transformers.utils import is_tf_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask


if is_tf_available():
			import tensorflow as tf

			from transformers import TFBlipTextModel
			from transformers.models.blip.modeling_tf_blip import TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST




class 							snake_case_       :

						"""simple docstring"""



						def __init__(self:					Optional[Any] ,					__UpperCAmelCase:					List[str] ,					__UpperCAmelCase:					int=12 ,					__UpperCAmelCase:					Dict=7 ,					__UpperCAmelCase:					str=True ,					__UpperCAmelCase:					Tuple=True ,					__UpperCAmelCase:					Tuple=True ,					__UpperCAmelCase:					Optional[int]=99 ,					__UpperCAmelCase:					str=32 ,					__UpperCAmelCase:					Any=32 ,					__UpperCAmelCase:					int=2 ,					__UpperCAmelCase:					List[str]=4 ,					__UpperCAmelCase:					Tuple=37 ,					__UpperCAmelCase:					Optional[int]=0.1 ,					__UpperCAmelCase:					List[Any]=0.1 ,					__UpperCAmelCase:					Dict=512 ,					__UpperCAmelCase:					Union[str, Any]=0.02 ,					__UpperCAmelCase:					List[Any]=0 ,					__UpperCAmelCase:					str=None ,					)    ->     Tuple:




											'''simple docstring'''



											__a					:						Union[str, Any]      =					parent
											__a					:						Dict      =					batch_size
											__a					:						Optional[Any]      =					seq_length
											__a					:						int      =					is_training
											__a					:						Union[str, Any]      =					use_input_mask
											__a					:						str      =					use_labels
											__a					:						Tuple      =					vocab_size
											__a					:						Dict      =					hidden_size
											__a					:						Optional[int]      =					projection_dim
											__a					:						Tuple      =					num_hidden_layers
											__a					:						Dict      =					num_attention_heads
											__a					:						Any      =					intermediate_size
											__a					:						Optional[int]      =					dropout
											__a					:						Dict      =					attention_dropout
											__a					:						List[Any]      =					max_position_embeddings
											__a					:						Any      =					initializer_range
											__a					:						Tuple      =					scope
											__a					:						Dict      =					bos_token_id



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




											'''simple docstring'''



											__a					:						Optional[Any]      =					ids_tensor([self.batch_size, self.seq_length] ,					self.vocab_size   )

											__a					:						Any      =					None
											if self.use_input_mask:
																__a					:						Tuple      =					random_attention_mask([self.batch_size, self.seq_length]   )

											if input_mask is not None:
																__a					:						Tuple      =					input_mask.numpy()
																__a      ,			__a					:						int      =					input_mask.shape
																__a					:						Dict      =					np.random.randint(1 ,					seq_length - 1 ,					size=(batch_size,)   )
																for batch_idx, start_index in enumerate(__UpperCAmelCase   ):
																					__a					:						Any      =					1
																					__a					:						int      =					0

											__a					:						Union[str, Any]      =					self.get_config()

											return config, input_ids, tf.convert_to_tensor(__UpperCAmelCase   )



						def        UpperCAmelCase__					(self:					List[str]   )    ->     Optional[int]:




											'''simple docstring'''



											return BlipTextConfig(
											    vocab_size=self.vocab_size ,					hidden_size=self.hidden_size ,					projection_dim=self.projection_dim ,					num_hidden_layers=self.num_hidden_layers ,					num_attention_heads=self.num_attention_heads ,					intermediate_size=self.intermediate_size ,					dropout=self.dropout ,					attention_dropout=self.attention_dropout ,					max_position_embeddings=self.max_position_embeddings ,					initializer_range=self.initializer_range ,					bos_token_id=self.bos_token_id ,					)



						def        UpperCAmelCase__					(self:					List[str] ,					__UpperCAmelCase:					Any ,					__UpperCAmelCase:					Dict ,					__UpperCAmelCase:					str   )    ->     List[str]:




											'''simple docstring'''



											__a					:						int      =					TFBlipTextModel(config=__UpperCAmelCase   )
											__a					:						List[str]      =					model(__UpperCAmelCase ,					attention_mask=__UpperCAmelCase ,					training=__UpperCAmelCase   )
											__a					:						Any      =					model(__UpperCAmelCase ,					training=__UpperCAmelCase   )
											self.parent.assertEqual(result.last_hidden_state.shape ,					(self.batch_size, self.seq_length, self.hidden_size)   )
											self.parent.assertEqual(result.pooler_output.shape ,					(self.batch_size, self.hidden_size)   )



						def        UpperCAmelCase__					(self:					List[str]   )    ->     str:




											'''simple docstring'''



											__a					:						Tuple      =					self.prepare_config_and_inputs()
											__a      ,			__a      ,			__a					:						Dict      =					config_and_inputs
											__a					:						Union[str, Any]      =					{"input_ids": input_ids, "attention_mask": input_mask}
											return config, inputs_dict




@require_tf
class 							snake_case_       (    __UpperCamelCase		,							unittest.TestCase      ):

						"""simple docstring"""



						snake_case__        =      (TFBlipTextModel,) if is_tf_available() else ()
						snake_case__        =      False
						snake_case__        =      False
						snake_case__        =      False



						def        UpperCAmelCase__					(self:					List[str]   )    ->     Optional[int]:




											'''simple docstring'''



											__a					:						str      =					BlipTextModelTester(self   )
											__a					:						str      =					ConfigTester(self ,					config_class=__UpperCAmelCase ,					hidden_size=37   )



						def        UpperCAmelCase__					(self:					str   )    ->     str:




											'''simple docstring'''



											self.config_tester.run_common_tests()



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




											'''simple docstring'''



											__a					:						int      =					self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*__UpperCAmelCase   )



						def        UpperCAmelCase__					(self:					Tuple   )    ->     Dict:




											'''simple docstring'''



											pass



						def        UpperCAmelCase__					(self:					Union[str, Any]   )    ->     Optional[int]:




											'''simple docstring'''



											pass



						@unittest.skip(reason="Blip does not use inputs_embeds"   )
						def        UpperCAmelCase__					(self:					Any   )    ->     Dict:




											'''simple docstring'''



											pass



						@unittest.skip(reason="BlipTextModel has no base class and is not available in MODEL_MAPPING"   )
						def        UpperCAmelCase__					(self:					List[Any]   )    ->     List[str]:




											'''simple docstring'''



											pass



						@unittest.skip(reason="BlipTextModel has no base class and is not available in MODEL_MAPPING"   )
						def        UpperCAmelCase__					(self:					Union[str, Any]   )    ->     int:




											'''simple docstring'''



											pass



						@slow
						def        UpperCAmelCase__					(self:					Optional[Any]   )    ->     Tuple:




											'''simple docstring'''



											for model_name in TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																__a					:						List[str]      =					TFBlipTextModel.from_pretrained(__UpperCAmelCase   )
																self.assertIsNotNone(__UpperCAmelCase   )



						def        UpperCAmelCase__					(self:					Dict ,					__UpperCAmelCase:					Optional[Any]=True   )    ->     Any:




											'''simple docstring'''



											super().test_pt_tf_model_equivalence(allow_missing_keys=__UpperCAmelCase   )





