




'''simple docstring'''


import copy
import os
from typing import Union

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


_snake_case : Tuple  				=						logging.get_logger(__name__)

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

class      A       (						_a       ):
							lowercase_							     =							'altclip_text_model'







							def __init__(    self			:    Optional[int]				,     lowerCAmelCase_			:    Dict=25_00_02				,     lowerCAmelCase_			:    int=10_24				,     lowerCAmelCase_			:    Any=24				,     lowerCAmelCase_			:    Tuple=16				,     lowerCAmelCase_			:    List[str]=40_96				,     lowerCAmelCase_			:    Tuple="gelu"				,     lowerCAmelCase_			:    Tuple=0.1				,     lowerCAmelCase_			:    int=0.1				,     lowerCAmelCase_			:    List[str]=5_14				,     lowerCAmelCase_			:    Optional[Any]=1				,     lowerCAmelCase_			:    int=0.0_2				,     lowerCAmelCase_			:    Tuple=0.0_2				,     lowerCAmelCase_			:    List[Any]=1e-05				,     lowerCAmelCase_			:    Union[str, Any]=1				,     lowerCAmelCase_			:    int=0				,     lowerCAmelCase_			:    Optional[Any]=2				,     lowerCAmelCase_			:    Optional[Any]="absolute"				,     lowerCAmelCase_			:    Dict=True				,     lowerCAmelCase_			:    Optional[int]=7_68				,     **lowerCAmelCase_			:    List[Any]				,     )     ->				List[str]:


														"""simple docstring"""


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

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



class      A       (						_a       ):
							lowercase_							     =							'altclip_vision_model'







							def __init__(    self			:    Any				,     lowerCAmelCase_			:    Optional[int]=7_68				,     lowerCAmelCase_			:    Tuple=30_72				,     lowerCAmelCase_			:    Tuple=5_12				,     lowerCAmelCase_			:    Any=12				,     lowerCAmelCase_			:    Union[str, Any]=12				,     lowerCAmelCase_			:    List[str]=3				,     lowerCAmelCase_			:    str=2_24				,     lowerCAmelCase_			:    Optional[int]=32				,     lowerCAmelCase_			:    List[Any]="quick_gelu"				,     lowerCAmelCase_			:    Optional[int]=1e-5				,     lowerCAmelCase_			:    Optional[Any]=0.0				,     lowerCAmelCase_			:    Tuple=0.0_2				,     lowerCAmelCase_			:    Tuple=1.0				,     **lowerCAmelCase_			:    List[Any]				,     )     ->				Optional[int]:


														"""simple docstring"""


														super().__init__(**lowerCAmelCase_   )

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







							@classmethod
							def   __lowerCAmelCase     (    cls			:    int				,     lowerCAmelCase_			:    Union[str, os.PathLike]				,     **lowerCAmelCase_			:    Optional[Any]   )     ->				"PretrainedConfig":


														"""simple docstring"""


														cls._set_token_in_kwargs(lowerCAmelCase_   )

														_a	,				_a      	=							cls.get_config_dict(lowerCAmelCase_				,     **lowerCAmelCase_   )

														# get the vision config dict if we are loading from AltCLIPConfig
														if config_dict.get('''model_type'''   ) == "altclip":
																					_a      	=							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(lowerCAmelCase_				,     **lowerCAmelCase_   )



class      A       (						_a       ):
							lowercase_							     =							'altclip'
							lowercase_							     =							True







							def __init__(    self			:    Union[str, Any]				,     lowerCAmelCase_			:    List[str]=None				,     lowerCAmelCase_			:    str=None				,     lowerCAmelCase_			:    Optional[int]=7_68				,     lowerCAmelCase_			:    List[Any]=2.6_5_9_2				,     **lowerCAmelCase_			:    Union[str, Any]   )     ->				List[Any]:


														"""simple docstring"""


														_a      	=							kwargs.pop('''text_config_dict'''				,     lowerCAmelCase_   )
														_a      	=							kwargs.pop('''vision_config_dict'''				,     lowerCAmelCase_   )

														super().__init__(**lowerCAmelCase_   )

														# 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      	=							{}

																					# This is the complete result when using `text_config_dict`.
																					_a      	=							AltCLIPTextConfig(**lowerCAmelCase_   ).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      	=							(
																																										    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      	=							(
																																										    F'`text_config_dict` is provided which will be used to initialize `AltCLIPTextConfig`. The '
																																										    F'value `text_config["{key}"]` will be overriden.'
																																										)
																																			logger.warning(lowerCAmelCase_   )

            # 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      	=							{}

																					# This is the complete result when using `vision_config_dict`.
																					_a      	=							AltCLIPVisionConfig(**lowerCAmelCase_   ).to_dict()
																					# convert keys to string instead of integer
																					if "id2label" in _vision_config_dict:
																												_a      	=							{
																												    str(lowerCAmelCase_   ): 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      	=							(
																																										    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      	=							(
																																										    F'`vision_config_dict` is provided which will be used to initialize `AltCLIPVisionConfig`. '
																																										    F'The value `vision_config["{key}"]` will be overriden.'
																																										)
																																			logger.warning(lowerCAmelCase_   )

            # 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      	=							{}
																					logger.info('''`text_config` is `None`. Initializing the `AltCLIPTextConfig` with default values.'''   )

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

														_a      	=							AltCLIPTextConfig(**lowerCAmelCase_   )
														_a      	=							AltCLIPVisionConfig(**lowerCAmelCase_   )

														_a      	=							projection_dim
														_a      	=							logit_scale_init_value
														_a      	=							1.0







							@classmethod
							def   __lowerCAmelCase     (    cls			:    List[Any]				,     lowerCAmelCase_			:    AltCLIPTextConfig				,     lowerCAmelCase_			:    AltCLIPVisionConfig				,     **lowerCAmelCase_			:    Union[str, Any]   )     ->				List[Any]:


														"""simple docstring"""


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







							def   __lowerCAmelCase     (    self			:    Any   )     ->				Optional[Any]:


														"""simple docstring"""


														_a      	=							copy.deepcopy(self.__dict__   )
														_a      	=							self.text_config.to_dict()
														_a      	=							self.vision_config.to_dict()
														_a      	=							self.__class__.model_type
														return output







'''simple docstring'''


from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


_snake_case : Optional[int]  				=						logging.get_logger(__name__)

_snake_case : Any  				=						{
    'junnyu/roformer_chinese_small': 'https://huggingface.co/junnyu/roformer_chinese_small/resolve/main/config.json',
    'junnyu/roformer_chinese_base': 'https://huggingface.co/junnyu/roformer_chinese_base/resolve/main/config.json',
    'junnyu/roformer_chinese_char_small': (
        'https://huggingface.co/junnyu/roformer_chinese_char_small/resolve/main/config.json'
    ),
    'junnyu/roformer_chinese_char_base': (
        'https://huggingface.co/junnyu/roformer_chinese_char_base/resolve/main/config.json'
    ),
    'junnyu/roformer_small_discriminator': (
        'https://huggingface.co/junnyu/roformer_small_discriminator/resolve/main/config.json'
    ),
    'junnyu/roformer_small_generator': (
        'https://huggingface.co/junnyu/roformer_small_generator/resolve/main/config.json'
    ),
    # See all RoFormer models at https://huggingface.co/models?filter=roformer
}

class      A       (						_a       ):
							lowercase_							     =							'roformer'







							def __init__(    self			:    str				,     lowerCAmelCase_			:    int=5_00_00				,     lowerCAmelCase_			:    Any=None				,     lowerCAmelCase_			:    int=7_68				,     lowerCAmelCase_			:    Tuple=12				,     lowerCAmelCase_			:    Any=12				,     lowerCAmelCase_			:    List[str]=30_72				,     lowerCAmelCase_			:    Dict="gelu"				,     lowerCAmelCase_			:    Optional[int]=0.1				,     lowerCAmelCase_			:    List[Any]=0.1				,     lowerCAmelCase_			:    int=15_36				,     lowerCAmelCase_			:    Optional[Any]=2				,     lowerCAmelCase_			:    int=0.0_2				,     lowerCAmelCase_			:    Dict=1e-12				,     lowerCAmelCase_			:    Any=0				,     lowerCAmelCase_			:    Optional[Any]=False				,     lowerCAmelCase_			:    Tuple=True				,     **lowerCAmelCase_			:    Optional[int]				,     )     ->				str:


														"""simple docstring"""


														super().__init__(pad_token_id=lowerCAmelCase_				,     **lowerCAmelCase_   )

														_a      	=							vocab_size
														_a      	=							hidden_size if embedding_size is None else embedding_size
														_a      	=							hidden_size
														_a      	=							num_hidden_layers
														_a      	=							num_attention_heads
														_a      	=							hidden_act
														_a      	=							intermediate_size
														_a      	=							hidden_dropout_prob
														_a      	=							attention_probs_dropout_prob
														_a      	=							max_position_embeddings
														_a      	=							type_vocab_size
														_a      	=							initializer_range
														_a      	=							layer_norm_eps
														_a      	=							rotary_value
														_a      	=							use_cache



class      A       (						_a       ):







							@property
							def   __lowerCAmelCase     (    self			:    Any   )     ->				Mapping[str, Mapping[int, str]]:


														"""simple docstring"""


														if self.task == "multiple-choice":
																					_a      	=							{0: '''batch''', 1: '''choice''', 2: '''sequence'''}
														else:
																					_a      	=							{0: '''batch''', 1: '''sequence'''}
														_a      	=							{0: '''batch''', 1: '''sequence'''}
														return OrderedDict(
														    [
														        ('''input_ids''', dynamic_axis),
														        ('''attention_mask''', dynamic_axis),
														        ('''token_type_ids''', dynamic_axis),
														    ]   )

