





"""simple docstring"""





import copy
import os
from typing import Union

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


lowerCAmelCase__     			=			logging.get_logger(__name__)

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





class        _lowerCamelCase      (       _lowercase ):
						UpperCAmelCase_ =			"altclip_text_model"


						def __init__(self   ,							__a=25_00_02   ,							__a=10_24   ,							__a=24   ,							__a=16   ,							__a=40_96   ,							__a="gelu"   ,							__a=0.1   ,							__a=0.1   ,							__a=5_14   ,							__a=1   ,							__a=0.02   ,							__a=0.02   ,							__a=1e-0_5   ,							__a=1   ,							__a=0   ,							__a=2   ,							__a="absolute"   ,							__a=True   ,							__a=7_68   ,							**__a   ,							) ->   Optional[Any]:
								super().__init__(pad_token_id=__a   ,							bos_token_id=__a   ,							eos_token_id=__a   ,							**__a		)

								UpperCamelCase   =	vocab_size
								UpperCamelCase   =	hidden_size
								UpperCamelCase   =	num_hidden_layers
								UpperCamelCase   =	num_attention_heads
								UpperCamelCase   =	hidden_act
								UpperCamelCase   =	intermediate_size
								UpperCamelCase   =	hidden_dropout_prob
								UpperCamelCase   =	attention_probs_dropout_prob
								UpperCamelCase   =	max_position_embeddings
								UpperCamelCase   =	type_vocab_size
								UpperCamelCase   =	initializer_range
								UpperCamelCase   =	initializer_factor
								UpperCamelCase   =	layer_norm_eps
								UpperCamelCase   =	position_embedding_type
								UpperCamelCase   =	use_cache
								UpperCamelCase   =	project_dim





class        _lowerCamelCase      (       _lowercase ):
						UpperCAmelCase_ =			"altclip_vision_model"


						def __init__(self   ,							__a=7_68   ,							__a=30_72   ,							__a=5_12   ,							__a=12   ,							__a=12   ,							__a=3   ,							__a=2_24   ,							__a=32   ,							__a="quick_gelu"   ,							__a=1e-5   ,							__a=0.0   ,							__a=0.02   ,							__a=1.0   ,							**__a   ,							) ->   List[str]:
								super().__init__(**__a		)

								UpperCamelCase   =	hidden_size
								UpperCamelCase   =	intermediate_size
								UpperCamelCase   =	projection_dim
								UpperCamelCase   =	num_hidden_layers
								UpperCamelCase   =	num_attention_heads
								UpperCamelCase   =	num_channels
								UpperCamelCase   =	patch_size
								UpperCamelCase   =	image_size
								UpperCamelCase   =	initializer_range
								UpperCamelCase   =	initializer_factor
								UpperCamelCase   =	attention_dropout
								UpperCamelCase   =	layer_norm_eps
								UpperCamelCase   =	hidden_act




						@classmethod
						def     snake_case_   (cls   ,							__a   ,							**__a		) ->   "PretrainedConfig":
								cls._set_token_in_kwargs(__a		)

								UpperCamelCase   ,				UpperCamelCase   =	cls.get_config_dict(__a   ,							**__a		)

								# get the vision config dict if we are loading from AltCLIPConfig
								if config_dict.get("model_type"		) == "altclip":
										UpperCamelCase   =	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        _lowerCamelCase      (       _lowercase ):
						UpperCAmelCase_ =			"altclip"
						UpperCAmelCase_ =			True


						def __init__(self   ,							__a=None   ,							__a=None   ,							__a=7_68   ,							__a=2.6592   ,							**__a		) ->   Any:
								# If `_config_dict` exist, we use them for the backward compatibility.
								# We pop out these 2 attributes before calling `super().__init__` to avoid them being saved (which causes a lot
								# of confusion!).
								UpperCamelCase   =	kwargs.pop("text_config_dict"   ,							__a		)
								UpperCamelCase   =	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:
												UpperCamelCase   =	{}

										# This is the complete result when using `text_config_dict`.
										UpperCamelCase   =	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:
																UpperCamelCase   =	(
																    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:
																UpperCamelCase   =	(
																    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:
												UpperCamelCase   =	{}

										# This is the complete result when using `vision_config_dict`.
										UpperCamelCase   =	AltCLIPVisionConfig(**__a		).to_dict()
										# convert keys to string instead of integer
										if "id2label" in _vision_config_dict:
												UpperCamelCase   =	{
												    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:
																UpperCamelCase   =	(
																    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:
																UpperCamelCase   =	(
																    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:
										UpperCamelCase   =	{}
										logger.info("`text_config` is `None`. Initializing the `AltCLIPTextConfig` with default values."		)

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

								UpperCamelCase   =	AltCLIPTextConfig(**__a		)
								UpperCamelCase   =	AltCLIPVisionConfig(**__a		)

								UpperCamelCase   =	projection_dim
								UpperCamelCase   =	logit_scale_init_value
								UpperCamelCase   =	1.0


						@classmethod
						def     snake_case_   (cls   ,							__a   ,							__a   ,							**__a		) ->   List[Any]:
								return cls(text_config=text_config.to_dict()   ,							vision_config=vision_config.to_dict()   ,							**__a		)




						def     snake_case_   (self		) ->   int:
								UpperCamelCase   =	copy.deepcopy(self.__dict__		)
								UpperCamelCase   =	self.text_config.to_dict()
								UpperCamelCase   =	self.vision_config.to_dict()
								UpperCamelCase   =	self.__class__.model_type
								return output













"""simple docstring"""





def       a__					(					_SCREAMING_SNAKE_CASE    ):




		"""simple docstring"""


		UpperCamelCase   =	0
		for ch in input_str:
				UpperCamelCase   =	ord(_SCREAMING_SNAKE_CASE    )
				UpperCamelCase   =	pow(2  ,	_SCREAMING_SNAKE_CASE    )

				# If we already turned on bit for current character's unicode
				if bitmap >> ch_unicode & 1 == 1:
						return False
				bitmap |= ch_bit_index_on
		return True


if __name__ == "__main__":
						import doctest

						doctest.testmod()






