


'''simple docstring'''




import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..bit import BitConfig


__snake_case    						=logging.get_logger(__name__)

__snake_case    						={
    """Intel/dpt-large""": """https://huggingface.co/Intel/dpt-large/resolve/main/config.json""",
    # See all DPT models at https://huggingface.co/models?filter=dpt
}

class 		UpperCAmelCase_      (  __lowercase		):
     lowerCamelCase				:	List[Any]		=     '''dpt'''





     def __init__( self       :      int    ,      UpperCAmelCase__       :      List[Any]=7_6_8    ,      UpperCAmelCase__       :      Optional[Any]=1_2    ,      UpperCAmelCase__       :      str=1_2    ,      UpperCAmelCase__       :      List[str]=3_0_7_2    ,      UpperCAmelCase__       :      Dict="gelu"    ,      UpperCAmelCase__       :      Optional[Any]=0.0    ,      UpperCAmelCase__       :      Dict=0.0    ,      UpperCAmelCase__       :      int=0.02    ,      UpperCAmelCase__       :      List[Any]=1E-12    ,      UpperCAmelCase__       :      List[str]=3_8_4    ,      UpperCAmelCase__       :      int=1_6    ,      UpperCAmelCase__       :      Optional[int]=3    ,      UpperCAmelCase__       :      List[str]=False    ,      UpperCAmelCase__       :      str=True    ,      UpperCAmelCase__       :      str=[2, 5, 8, 1_1]    ,      UpperCAmelCase__       :      Union[str, Any]="project"    ,      UpperCAmelCase__       :      List[Any]=[4, 2, 1, 0.5]    ,      UpperCAmelCase__       :      List[Any]=[9_6, 1_9_2, 3_8_4, 7_6_8]    ,      UpperCAmelCase__       :      Any=2_5_6    ,      UpperCAmelCase__       :      Optional[Any]=-1    ,      UpperCAmelCase__       :      List[str]=False    ,      UpperCAmelCase__       :      Optional[int]=True    ,      UpperCAmelCase__       :      Dict=0.4    ,      UpperCAmelCase__       :      Any=2_5_5    ,      UpperCAmelCase__       :      List[str]=0.1    ,      UpperCAmelCase__       :      Dict=[1, 1_0_2_4, 2_4, 2_4]    ,      UpperCAmelCase__       :      Any=[0, 1]    ,      UpperCAmelCase__       :      Dict=None    ,      **UpperCAmelCase__       :      str    ,      )				->  int:
        super().__init__(**UpperCAmelCase__    )

        lowerCAmelCase     =			hidden_size
        lowerCAmelCase     =			is_hybrid

        if self.is_hybrid:
           if backbone_config is None:
              logger.info('Initializing the config with a `BiT` backbone.'    )
              lowerCAmelCase     =			{
                  'global_padding': 'same',
                  'layer_type': 'bottleneck',
                  'depths': [3, 4, 9],
                  'out_features': ['stage1', 'stage2', 'stage3'],
                  'embedding_dynamic_padding': True,
              }
              lowerCAmelCase     =			BitConfig(**UpperCAmelCase__    )
           elif isinstance(UpperCAmelCase__    ,      UpperCAmelCase__    ):
              logger.info('Initializing the config with a `BiT` backbone.'    )
              lowerCAmelCase     =			BitConfig(**UpperCAmelCase__    )
           elif isinstance(UpperCAmelCase__    ,      UpperCAmelCase__    ):
              lowerCAmelCase     =			backbone_config
           else:
              raise ValueError(
                  F'''backbone_config must be a dictionary or a `PretrainedConfig`, got {backbone_config.__class__}.'''    )

           lowerCAmelCase     =			backbone_featmap_shape
           lowerCAmelCase     =			neck_ignore_stages

           if readout_type != "project":
              raise ValueError('Readout type must be \'project\' when using `DPT-hybrid` mode.'    )
        else:
           lowerCAmelCase     =			None
           lowerCAmelCase     =			None
           lowerCAmelCase     =			[]

        lowerCAmelCase     =			num_hidden_layers
        lowerCAmelCase     =			num_attention_heads
        lowerCAmelCase     =			intermediate_size
        lowerCAmelCase     =			hidden_act
        lowerCAmelCase     =			hidden_dropout_prob
        lowerCAmelCase     =			attention_probs_dropout_prob
        lowerCAmelCase     =			initializer_range
        lowerCAmelCase     =			layer_norm_eps
        lowerCAmelCase     =			image_size
        lowerCAmelCase     =			patch_size
        lowerCAmelCase     =			num_channels
        lowerCAmelCase     =			qkv_bias
        lowerCAmelCase     =			backbone_out_indices
        if readout_type not in ["ignore", "add", "project"]:
           raise ValueError('Readout_type must be one of [\'ignore\', \'add\', \'project\']'    )
        lowerCAmelCase     =			readout_type
        lowerCAmelCase     =			reassemble_factors
        lowerCAmelCase     =			neck_hidden_sizes
        lowerCAmelCase     =			fusion_hidden_size
        lowerCAmelCase     =			head_in_index
        lowerCAmelCase     =			use_batch_norm_in_fusion_residual
        # auxiliary head attributes (semantic segmentation)
        lowerCAmelCase     =			use_auxiliary_head
        lowerCAmelCase     =			auxiliary_loss_weight
        lowerCAmelCase     =			semantic_loss_ignore_index
        lowerCAmelCase     =			semantic_classifier_dropout





     def 							__UpperCAmelCase      ( self       :      str    )				->  Dict:
        lowerCAmelCase     =			copy.deepcopy(self.__dict__    )

        if output["backbone_config"] is not None:
           lowerCAmelCase     =			self.backbone_config.to_dict()

        lowerCAmelCase     =			self.__class__.model_type
        return output










import unittest

from diffusers.pipelines.pipeline_utils import is_safetensors_compatible

class     _A       (	unittest.TestCase    ):



       def 		_lowerCamelCase			(		self							:     List[Any]):


           '''simple docstring'''

           __a						       =				[
               '''safety_checker/pytorch_model.bin''',
               '''safety_checker/model.safetensors''',
               '''vae/diffusion_pytorch_model.bin''',
               '''vae/diffusion_pytorch_model.safetensors''',
               '''text_encoder/pytorch_model.bin''',
               '''text_encoder/model.safetensors''',
               '''unet/diffusion_pytorch_model.bin''',
               '''unet/diffusion_pytorch_model.safetensors''',
           ]
           self.assertTrue(is_safetensors_compatible(__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Optional[Any]):


           '''simple docstring'''

           __a						       =				[
               '''unet/diffusion_pytorch_model.bin''',
               '''unet/diffusion_pytorch_model.safetensors''',
           ]
           self.assertTrue(is_safetensors_compatible(__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Optional[Any]):


           '''simple docstring'''

           __a						       =				[
               '''safety_checker/pytorch_model.bin''',
               '''safety_checker/model.safetensors''',
               '''vae/diffusion_pytorch_model.bin''',
               '''vae/diffusion_pytorch_model.safetensors''',
               '''text_encoder/pytorch_model.bin''',
               '''text_encoder/model.safetensors''',
               '''unet/diffusion_pytorch_model.bin''',
               # Removed: 'unet/diffusion_pytorch_model.safetensors',
           ]
           self.assertFalse(is_safetensors_compatible(__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Dict):


           '''simple docstring'''

           __a						       =				[
               '''text_encoder/pytorch_model.bin''',
               '''text_encoder/model.safetensors''',
           ]
           self.assertTrue(is_safetensors_compatible(__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Union[str, Any]):


           '''simple docstring'''

           __a						       =				[
               '''safety_checker/pytorch_model.bin''',
               '''safety_checker/model.safetensors''',
               '''vae/diffusion_pytorch_model.bin''',
               '''vae/diffusion_pytorch_model.safetensors''',
               '''text_encoder/pytorch_model.bin''',
               # Removed: 'text_encoder/model.safetensors',
               '''unet/diffusion_pytorch_model.bin''',
               '''unet/diffusion_pytorch_model.safetensors''',
           ]
           self.assertFalse(is_safetensors_compatible(__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Tuple):


           '''simple docstring'''

           __a						       =				[
               '''safety_checker/pytorch_model.fp16.bin''',
               '''safety_checker/model.fp16.safetensors''',
               '''vae/diffusion_pytorch_model.fp16.bin''',
               '''vae/diffusion_pytorch_model.fp16.safetensors''',
               '''text_encoder/pytorch_model.fp16.bin''',
               '''text_encoder/model.fp16.safetensors''',
               '''unet/diffusion_pytorch_model.fp16.bin''',
               '''unet/diffusion_pytorch_model.fp16.safetensors''',
           ]
           __a						       =				'''fp16'''
           self.assertTrue(is_safetensors_compatible(__SCREAMING_SNAKE_CASE     ,		variant=__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Dict):


           '''simple docstring'''

           __a						       =				[
               '''unet/diffusion_pytorch_model.fp16.bin''',
               '''unet/diffusion_pytorch_model.fp16.safetensors''',
           ]
           __a						       =				'''fp16'''
           self.assertTrue(is_safetensors_compatible(__SCREAMING_SNAKE_CASE     ,		variant=__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Optional[Any]):


           '''simple docstring'''

           __a						       =				[
               '''unet/diffusion_pytorch_model.bin''',
               '''unet/diffusion_pytorch_model.safetensors''',
           ]
           __a						       =				'''fp16'''
           self.assertTrue(is_safetensors_compatible(__SCREAMING_SNAKE_CASE     ,		variant=__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Union[str, Any]):


           '''simple docstring'''

           __a						       =				[
               '''safety_checker/pytorch_model.fp16.bin''',
               '''safety_checker/model.fp16.safetensors''',
               '''vae/diffusion_pytorch_model.fp16.bin''',
               '''vae/diffusion_pytorch_model.fp16.safetensors''',
               '''text_encoder/pytorch_model.fp16.bin''',
               '''text_encoder/model.fp16.safetensors''',
               '''unet/diffusion_pytorch_model.fp16.bin''',
               # Removed: 'unet/diffusion_pytorch_model.fp16.safetensors',
           ]
           __a						       =				'''fp16'''
           self.assertFalse(is_safetensors_compatible(__SCREAMING_SNAKE_CASE     ,		variant=__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     Dict):


           '''simple docstring'''

           __a						       =				[
               '''text_encoder/pytorch_model.fp16.bin''',
               '''text_encoder/model.fp16.safetensors''',
           ]
           __a						       =				'''fp16'''
           self.assertTrue(is_safetensors_compatible(__SCREAMING_SNAKE_CASE     ,		variant=__SCREAMING_SNAKE_CASE))



       def 		_lowerCamelCase			(		self							:     List[str]):


           '''simple docstring'''

           __a						       =				[
               '''text_encoder/pytorch_model.bin''',
               '''text_encoder/model.safetensors''',
           ]
           __a						       =				'''fp16'''
           self.assertTrue(is_safetensors_compatible(__SCREAMING_SNAKE_CASE     ,		variant=__SCREAMING_SNAKE_CASE))





       def 		_lowerCamelCase			(		self							:     List[str]):


           '''simple docstring'''

           __a						       =				[
               '''safety_checker/pytorch_model.fp16.bin''',
               '''safety_checker/model.fp16.safetensors''',
               '''vae/diffusion_pytorch_model.fp16.bin''',
               '''vae/diffusion_pytorch_model.fp16.safetensors''',
               '''text_encoder/pytorch_model.fp16.bin''',
               # 'text_encoder/model.fp16.safetensors',
               '''unet/diffusion_pytorch_model.fp16.bin''',
               '''unet/diffusion_pytorch_model.fp16.safetensors''',
           ]
           __a						       =				'''fp16'''
           self.assertFalse(is_safetensors_compatible(__SCREAMING_SNAKE_CASE     ,		variant=__SCREAMING_SNAKE_CASE))





