





'''simple docstring'''



from dataclasses import dataclass
from enum import Enum
from typing import List, Optional, Union

import numpy as np
import PIL
from PIL import Image

from ...utils import BaseOutput, is_torch_available, is_transformers_available






@dataclass
class 							__lowercase    ( lowerCAmelCase__  ):







	'''simple docstring'''

	a      :			Union[List[PIL.Image.Image], np.ndarray]
	a      :			Optional[List[bool]]


if is_transformers_available() and is_torch_available():
	from .pipeline_semantic_stable_diffusion import SemanticStableDiffusionPipeline












'''simple docstring'''



import copy

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


_SCREAMING_SNAKE_CASE   =      logging.get_logger(__name__)

_SCREAMING_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 							__lowercase    ( lowerCAmelCase__  ):







	'''simple docstring'''

	a      :			Union[str, Any]     =    "dpt"


	def __init__(self       ,_lowerCamelCase=768       ,_lowerCamelCase=12       ,_lowerCamelCase=12       ,_lowerCamelCase=3072       ,_lowerCamelCase="gelu"       ,_lowerCamelCase=0.0       ,_lowerCamelCase=0.0       ,_lowerCamelCase=0.0_2       ,_lowerCamelCase=1E-1_2       ,_lowerCamelCase=384       ,_lowerCamelCase=16       ,_lowerCamelCase=3       ,_lowerCamelCase=False       ,_lowerCamelCase=True       ,_lowerCamelCase=[2, 5, 8, 11]       ,_lowerCamelCase="project"       ,_lowerCamelCase=[4, 2, 1, 0.5]       ,_lowerCamelCase=[96, 192, 384, 768]       ,_lowerCamelCase=256       ,_lowerCamelCase=-1       ,_lowerCamelCase=False       ,_lowerCamelCase=True       ,_lowerCamelCase=0.4       ,_lowerCamelCase=255       ,_lowerCamelCase=0.1       ,_lowerCamelCase=[1, 1024, 24, 24]       ,_lowerCamelCase=[0, 1]       ,_lowerCamelCase=None       ,**_lowerCamelCase       ,)							->							Tuple:







				'''simple docstring'''





				super().__init__(**_lowerCamelCase	)

				__lowercase			  =							hidden_size
				__lowercase			  =							is_hybrid

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

							__lowercase			  =							backbone_featmap_shape
							__lowercase			  =							neck_ignore_stages

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

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


	def   _UpperCAmelCase       (self	)							->							Union[str, Any]:







				'''simple docstring'''





				__lowercase			  =							copy.deepcopy(self.__dict__	)

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

				__lowercase			  =							self.__class__.model_type
				return output





