




"""simple docstring"""





import copy

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


_lowercase							=			logging.get_logger(__name__)

class 					__lowercase				(	__snake_case		):


				'''simple docstring'''


				_lowerCAmelCase			='hybrid-clip'
				_lowerCAmelCase			=True

				def __init__(      self      :   Union[str, Any]					,SCREAMING_SNAKE_CASE_      :   Union[str, Any]=5_1_2					,**SCREAMING_SNAKE_CASE_      :   List[str]					):
										super().__init__(**SCREAMING_SNAKE_CASE_					)

										if "text_config" not in kwargs:
																raise ValueError('''`text_config` can not be `None`.'''					)

										if "vision_config" not in kwargs:
																raise ValueError('''`vision_config` can not be `None`.'''					)

										snake_case__				:    Any								=    kwargs.pop('''text_config'''					)
										snake_case__				:    Optional[Any]								=    kwargs.pop('''vision_config'''					)

										snake_case__				:    str								=    text_config.pop('''model_type'''					)
										snake_case__				:    Optional[int]								=    vision_config.pop('''model_type'''					)

										from transformers import AutoConfig

										snake_case__				:    Optional[int]								=    AutoConfig.for_model(SCREAMING_SNAKE_CASE_					,**SCREAMING_SNAKE_CASE_					)

										if vision_model_type == "clip":
																snake_case__				:    List[Any]								=    AutoConfig.for_model(SCREAMING_SNAKE_CASE_					,**SCREAMING_SNAKE_CASE_					).vision_config
										elif vision_model_type == "clip_vision_model":
																from transformers import CLIPVisionConfig

																snake_case__				:    Any								=    CLIPVisionConfig(**SCREAMING_SNAKE_CASE_					)
										else:
																snake_case__				:    Optional[Any]								=    AutoConfig.for_model(SCREAMING_SNAKE_CASE_					,**SCREAMING_SNAKE_CASE_					)

										snake_case__				:    Dict								=    projection_dim
										snake_case__				:    int								=    1.0

				@classmethod
				def 					_lowerCamelCase    (      cls      :   List[str]					,SCREAMING_SNAKE_CASE_      :   str					,SCREAMING_SNAKE_CASE_      :   List[Any]					,**SCREAMING_SNAKE_CASE_      :   Optional[Any]					):
										return cls(text_config=text_config.to_dict()					,vision_config=vision_config.to_dict()					,**SCREAMING_SNAKE_CASE_					)





				def 					_lowerCamelCase    (      self      :   Optional[int]					):
										snake_case__				:    Optional[int]								=    copy.deepcopy(self.__dict__					)
										snake_case__				:    List[Any]								=    self.text_config.to_dict()
										snake_case__				:    Any								=    self.vision_config.to_dict()
										snake_case__				:    Any								=    self.__class__.model_type
										return output



from dataclasses import dataclass
from typing import Callable, Optional

import datasets


@dataclass
class 						a__							(   datasets.BuilderConfig		):
			A__				:   Optional[Callable]								=			None
			A__				:   Optional[dict]								=			None
			A__				:   Optional[datasets.Features]								=			None



			def __SCREAMING_SNAKE_CASE							(						self    ) ->    Any:
								assert self.generator is not None, "generator must be specified"

								if self.gen_kwargs is None:
													__a							=   {}






class 						a__							(   datasets.GeneratorBasedBuilder		):
			A__				:   List[Any]								=			GeneratorConfig



			def __SCREAMING_SNAKE_CASE							(						self    ) ->    Tuple:
								return datasets.DatasetInfo(features=self.config.features    )



			def __SCREAMING_SNAKE_CASE							(						self      ,						UpperCAmelCase    ) ->    Optional[int]:
								return [datasets.SplitGenerator(name=datasets.Split.TRAIN      ,						gen_kwargs=self.config.gen_kwargs    )]







			def __SCREAMING_SNAKE_CASE							(						self      ,						**UpperCAmelCase    ) ->    Tuple:
								for idx, ex in enumerate(self.config.generator(**UpperCAmelCase    )    ):
													yield idx, ex




