
import copy
import os
from typing import TYPE_CHECKING, List, Union


if TYPE_CHECKING:
		pass

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


A		: Any								=     logging.get_logger(__name__)

A		: Optional[Any]								=     {
    '''kakaobrain/align-base''': '''https://huggingface.co/kakaobrain/align-base/resolve/main/config.json''',
}



class    a_ (			_a    ):
			a	:			Tuple					   =							'''align_text_model'''






			def __init__(      self				,			__UpperCamelCase=30_522				,			__UpperCamelCase=768				,			__UpperCamelCase=12				,			__UpperCamelCase=12				,			__UpperCamelCase=3_072				,			__UpperCamelCase="gelu"				,			__UpperCamelCase=0.1				,			__UpperCamelCase=0.1				,			__UpperCamelCase=512				,			__UpperCamelCase=2				,			__UpperCamelCase=0.02				,			__UpperCamelCase=1E-12				,			__UpperCamelCase=0				,			__UpperCamelCase="absolute"				,			__UpperCamelCase=True				,			**__UpperCamelCase				,			):
									super().__init__(**__UpperCamelCase  )

									_lowercase					       =					vocab_size
									_lowercase					       =					hidden_size
									_lowercase					       =					num_hidden_layers
									_lowercase					       =					num_attention_heads
									_lowercase					       =					hidden_act
									_lowercase					       =					intermediate_size
									_lowercase					       =					hidden_dropout_prob
									_lowercase					       =					attention_probs_dropout_prob
									_lowercase					       =					max_position_embeddings
									_lowercase					       =					type_vocab_size
									_lowercase					       =					initializer_range
									_lowercase					       =					layer_norm_eps
									_lowercase					       =					position_embedding_type
									_lowercase					       =					use_cache
									_lowercase					       =					pad_token_id






			@classmethod
			def    UpperCamelCase_				(      cls				,			__UpperCamelCase				,			**__UpperCamelCase  ):
									cls._set_token_in_kwargs(__UpperCamelCase  )

									_lowercase       ,						_lowercase					       =					cls.get_config_dict(__UpperCamelCase				,			**__UpperCamelCase  )

									# get the text config dict if we are loading from AlignConfig
									if config_dict.get("""model_type"""  ) == "align":
															_lowercase					       =					config_dict["""text_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(__UpperCamelCase				,			**__UpperCamelCase  )







class    a_ (			_a    ):
			a	:			List[Any]					   =							'''align_vision_model'''






			def __init__(      self				,			__UpperCamelCase = 3				,			__UpperCamelCase = 600				,			__UpperCamelCase = 2.0				,			__UpperCamelCase = 3.1				,			__UpperCamelCase = 8				,			__UpperCamelCase = [3, 3, 5, 3, 5, 5, 3]				,			__UpperCamelCase = [32, 16, 24, 40, 80, 112, 192]				,			__UpperCamelCase = [16, 24, 40, 80, 112, 192, 320]				,			__UpperCamelCase = []				,			__UpperCamelCase = [1, 2, 2, 2, 1, 2, 1]				,			__UpperCamelCase = [1, 2, 2, 3, 3, 4, 1]				,			__UpperCamelCase = [1, 6, 6, 6, 6, 6, 6]				,			__UpperCamelCase = 0.25				,			__UpperCamelCase = "swish"				,			__UpperCamelCase = 2_560				,			__UpperCamelCase = "mean"				,			__UpperCamelCase = 0.02				,			__UpperCamelCase = 0.0_01				,			__UpperCamelCase = 0.99				,			__UpperCamelCase = 0.2				,			**__UpperCamelCase				,			):
									super().__init__(**__UpperCamelCase  )

									_lowercase					       =					num_channels
									_lowercase					       =					image_size
									_lowercase					       =					width_coefficient
									_lowercase					       =					depth_coefficient
									_lowercase					       =					depth_divisor
									_lowercase					       =					kernel_sizes
									_lowercase					       =					in_channels
									_lowercase					       =					out_channels
									_lowercase					       =					depthwise_padding
									_lowercase					       =					strides
									_lowercase					       =					num_block_repeats
									_lowercase					       =					expand_ratios
									_lowercase					       =					squeeze_expansion_ratio
									_lowercase					       =					hidden_act
									_lowercase					       =					hidden_dim
									_lowercase					       =					pooling_type
									_lowercase					       =					initializer_range
									_lowercase					       =					batch_norm_eps
									_lowercase					       =					batch_norm_momentum
									_lowercase					       =					drop_connect_rate
									_lowercase					       =					sum(__UpperCamelCase  ) * 4






			@classmethod
			def    UpperCamelCase_				(      cls				,			__UpperCamelCase				,			**__UpperCamelCase  ):
									cls._set_token_in_kwargs(__UpperCamelCase  )

									_lowercase       ,						_lowercase					       =					cls.get_config_dict(__UpperCamelCase				,			**__UpperCamelCase  )

									# get the vision config dict if we are loading from AlignConfig
									if config_dict.get("""model_type"""  ) == "align":
															_lowercase					       =					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(__UpperCamelCase				,			**__UpperCamelCase  )







class    a_ (			_a    ):
			a	:			Optional[Any]					   =							'''align'''
			a	:			int					   =							True






			def __init__(      self				,			__UpperCamelCase=None				,			__UpperCamelCase=None				,			__UpperCamelCase=640				,			__UpperCamelCase=1.0				,			__UpperCamelCase=0.02				,			**__UpperCamelCase				,			):
									super().__init__(**__UpperCamelCase  )

									if text_config is None:
															_lowercase					       =					{}
															logger.info("""text_config is None. Initializing the AlignTextConfig with default values."""  )

									if vision_config is None:
															_lowercase					       =					{}
															logger.info("""vision_config is None. Initializing the AlignVisionConfig with default values."""  )

									_lowercase					       =					AlignTextConfig(**__UpperCamelCase  )
									_lowercase					       =					AlignVisionConfig(**__UpperCamelCase  )

									_lowercase					       =					projection_dim
									_lowercase					       =					temperature_init_value
									_lowercase					       =					initializer_range






			@classmethod
			def    UpperCamelCase_				(      cls				,			__UpperCamelCase				,			__UpperCamelCase				,			**__UpperCamelCase  ):
									return cls(text_config=text_config.to_dict()				,			vision_config=vision_config.to_dict()				,			**__UpperCamelCase  )






			def    UpperCamelCase_				(      self  ):
									_lowercase					       =					copy.deepcopy(self.__dict__  )
									_lowercase					       =					self.text_config.to_dict()
									_lowercase					       =					self.vision_config.to_dict()
									_lowercase					       =					self.__class__.model_type
									return output

from ...utils import (
    OptionalDependencyNotAvailable,
    is_torch_available,
    is_transformers_available,
    is_transformers_version,
)


try:
		if not (is_transformers_available() and is_torch_available()):
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		from ...utils.dummy_torch_and_transformers_objects import ShapEPipeline
else:
		from .camera import create_pan_cameras
		from .pipeline_shap_e import ShapEPipeline
		from .pipeline_shap_e_img2img import ShapEImgaImgPipeline
		from .renderer import (
		    BoundingBoxVolume,
		    ImportanceRaySampler,
		    MLPNeRFModelOutput,
		    MLPNeRSTFModel,
		    ShapEParamsProjModel,
		    ShapERenderer,
		    StratifiedRaySampler,
		    VoidNeRFModel,
		)