


'''simple docstring'''



import copy
import os
from typing import Union

from ...configuration_utils import PretrainedConfig
from ...utils import logging


__lowercase	:						Dict       =	logging.get_logger(__name__)

__lowercase	:						int       =	{
    'BAAI/AltCLIP': 'https://huggingface.co/BAAI/AltCLIP/resolve/main/config.json',
    # See all AltCLIP models at https://huggingface.co/models?filter=altclip
}





class 							__UpperCamelCase				(		lowerCAmelCase_					):
	A_				=    "altclip_text_model"




	def __init__(   self						,				__a=25_0002						,				__a=1024						,				__a=24						,				__a=16						,				__a=4096						,				__a="gelu"						,				__a=0.1						,				__a=0.1						,				__a=514						,				__a=1						,				__a=0.02						,				__a=0.02						,				__a=1E-0_5						,				__a=1						,				__a=0						,				__a=2						,				__a="absolute"						,				__a=True						,				__a=768						,				**__a						,				):

						'''simple docstring'''





						super().__init__(pad_token_id=__a						,				bos_token_id=__a						,				eos_token_id=__a						,				**__a							)

						__a			:       Dict					    =  vocab_size
						__a			:       List[Any]					    =  hidden_size
						__a			:       Optional[Any]					    =  num_hidden_layers
						__a			:       Dict					    =  num_attention_heads
						__a			:       List[Any]					    =  hidden_act
						__a			:       Tuple					    =  intermediate_size
						__a			:       Optional[int]					    =  hidden_dropout_prob
						__a			:       Dict					    =  attention_probs_dropout_prob
						__a			:       Tuple					    =  max_position_embeddings
						__a			:       Union[str, Any]					    =  type_vocab_size
						__a			:       Tuple					    =  initializer_range
						__a			:       List[str]					    =  initializer_factor
						__a			:       Optional[Any]					    =  layer_norm_eps
						__a			:       List[str]					    =  position_embedding_type
						__a			:       int					    =  use_cache
						__a			:       Any					    =  project_dim





class 							__UpperCamelCase				(		lowerCAmelCase_					):
	A_				=    "altclip_vision_model"




	def __init__(   self						,				__a=768						,				__a=3072						,				__a=512						,				__a=12						,				__a=12						,				__a=3						,				__a=224						,				__a=32						,				__a="quick_gelu"						,				__a=1E-5						,				__a=0.0						,				__a=0.02						,				__a=1.0						,				**__a						,				):

						'''simple docstring'''





						super().__init__(**__a							)

						__a			:       str					    =  hidden_size
						__a			:       Dict					    =  intermediate_size
						__a			:       str					    =  projection_dim
						__a			:       Optional[int]					    =  num_hidden_layers
						__a			:       Optional[Any]					    =  num_attention_heads
						__a			:       Dict					    =  num_channels
						__a			:       Union[str, Any]					    =  patch_size
						__a			:       List[Any]					    =  image_size
						__a			:       Any					    =  initializer_range
						__a			:       Tuple					    =  initializer_factor
						__a			:       str					    =  attention_dropout
						__a			:       Union[str, Any]					    =  layer_norm_eps
						__a			:       Union[str, Any]					    =  hidden_act





	@classmethod
	def       __UpperCAmelCase							(   cls						,				__a						,				**__a							):

						'''simple docstring'''





						cls._set_token_in_kwargs(__a							)

						__a    ,				__a			:       List[str]					    =  cls.get_config_dict(__a						,				**__a							)

						# get the vision config dict if we are loading from AltCLIPConfig
						if config_dict.get('model_type'							) == "altclip":
											__a			:       List[str]					    =  config_dict['vision_config']

						if "model_type" in config_dict and hasattr(cls						,				'model_type'							) and config_dict["model_type"] != cls.model_type:
											logger.warning(
											    f"""You are using a model of type {config_dict["model_type"]} to instantiate a model of type """
											    f"""{cls.model_type}. This is not supported for all configurations of models and can yield errors."""							)

						return cls.from_dict(__a						,				**__a							)





class 							__UpperCamelCase				(		lowerCAmelCase_					):
	A_				=    "altclip"
	A_				=    True




	def __init__(   self						,				__a=None						,				__a=None						,				__a=768						,				__a=2.6592						,				**__a							):

						'''simple docstring'''





						__a			:       str					    =  kwargs.pop('text_config_dict'						,				__a							)
						__a			:       List[str]					    =  kwargs.pop('vision_config_dict'						,				__a							)

						super().__init__(**__a							)

						# Instead of simply assigning `[text|vision]_config_dict` to `[text|vision]_config`, we use the values in
						# `[text|vision]_config_dict` to update the values in `[text|vision]_config`. The values should be same in most
						# cases, but we don't want to break anything regarding `_config_dict` that existed before commit `8827e1b2`.
						if text_config_dict is not None:
											if text_config is None:
																__a			:       Dict					    =  {}

											# This is the complete result when using `text_config_dict`.
											__a			:       Any					    =  AltCLIPTextConfig(**__a							).to_dict()

											# Give a warning if the values exist in both `_text_config_dict` and `text_config` but being different.
											for key, value in _text_config_dict.items():
																if key in text_config and value != text_config[key] and key not in ["transformers_version"]:
																					# If specified in `text_config_dict`
																					if key in text_config_dict:
																										__a			:       Tuple					    =  (
																										    f"""`{key}` is found in both `text_config_dict` and `text_config` but with different values. """
																										    f"""The value `text_config_dict[\"{key}\"]` will be used instead."""
																										)
																					# If inferred from default argument values (just to be super careful)
																					else:
																										__a			:       List[Any]					    =  (
																										    f"""`text_config_dict` is provided which will be used to initialize `AltCLIPTextConfig`. The """
																										    f"""value `text_config[\"{key}\"]` will be overriden."""
																										)
																					logger.warning(__a							)

            # Update all values in `text_config` with the ones in `_text_config_dict`.
											text_config.update(_text_config_dict							)

						if vision_config_dict is not None:
											if vision_config is None:
																__a			:       Optional[int]					    =  {}

											# This is the complete result when using `vision_config_dict`.
											__a			:       Union[str, Any]					    =  AltCLIPVisionConfig(**__a							).to_dict()
											# convert keys to string instead of integer
											if "id2label" in _vision_config_dict:
																__a			:       Dict					    =  {
																    str(__a							): value for key, value in _vision_config_dict['id2label'].items()
																}

											# Give a warning if the values exist in both `_vision_config_dict` and `vision_config` but being different.
											for key, value in _vision_config_dict.items():
																if key in vision_config and value != vision_config[key] and key not in ["transformers_version"]:
																					# If specified in `vision_config_dict`
																					if key in vision_config_dict:
																										__a			:       Optional[Any]					    =  (
																										    f"""`{key}` is found in both `vision_config_dict` and `vision_config` but with different """
																										    f"""values. The value `vision_config_dict[\"{key}\"]` will be used instead."""
																										)
																					# If inferred from default argument values (just to be super careful)
																					else:
																										__a			:       Any					    =  (
																										    f"""`vision_config_dict` is provided which will be used to initialize `AltCLIPVisionConfig`. """
																										    f"""The value `vision_config[\"{key}\"]` will be overriden."""
																										)
																					logger.warning(__a							)

            # Update all values in `vision_config` with the ones in `_vision_config_dict`.
											vision_config.update(_vision_config_dict							)

						if text_config is None:
											__a			:       int					    =  {}
											logger.info('`text_config` is `None`. Initializing the `AltCLIPTextConfig` with default values.'							)

						if vision_config is None:
											__a			:       Tuple					    =  {}
											logger.info('`vision_config` is `None`. initializing the `AltCLIPVisionConfig` with default values.'							)

						__a			:       int					    =  AltCLIPTextConfig(**__a							)
						__a			:       Union[str, Any]					    =  AltCLIPVisionConfig(**__a							)

						__a			:       Optional[int]					    =  projection_dim
						__a			:       List[Any]					    =  logit_scale_init_value
						__a			:       Any					    =  1.0




	@classmethod
	def       __UpperCAmelCase							(   cls						,				__a						,				__a						,				**__a							):

						'''simple docstring'''





						return cls(text_config=text_config.to_dict()						,				vision_config=vision_config.to_dict()						,				**__a							)





	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       Optional[int]					    =  copy.deepcopy(self.__dict__							)
						__a			:       Optional[Any]					    =  self.text_config.to_dict()
						__a			:       Optional[Any]					    =  self.vision_config.to_dict()
						__a			:       Dict					    =  self.__class__.model_type
						return output





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 							UpperCAmelCase_		(							):
	lowercase       =    Github(os.environ['GITHUB_TOKEN']							)
	lowercase       =    g.get_repo('huggingface/diffusers'							)
	lowercase       =    repo.get_issues(state='open'							)

	for issue in open_issues:
		lowercase       =    sorted(issue.get_comments() ,							key=lambda __SCREAMING_SNAKE_CASE							: i.created_at ,							reverse=__SCREAMING_SNAKE_CASE							)
		lowercase       =    comments[0] if len(__SCREAMING_SNAKE_CASE							) > 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()

