


"""simple docstring"""


from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tokenizers_available,
    is_torch_available,
    is_vision_available,
)


UpperCamelCase						:				Optional[int]             =      {
    "configuration_perceiver": ["PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP", "PerceiverConfig", "PerceiverOnnxConfig"],
    "tokenization_perceiver": ["PerceiverTokenizer"],
}

try:
	if not is_vision_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	UpperCamelCase						:				str             =      ["PerceiverFeatureExtractor"]
	UpperCamelCase						:				Any             =      ["PerceiverImageProcessor"]

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	UpperCamelCase						:				Union[str, Any]             =      [
	    "PERCEIVER_PRETRAINED_MODEL_ARCHIVE_LIST",
	    "PerceiverForImageClassificationConvProcessing",
	    "PerceiverForImageClassificationFourier",
	    "PerceiverForImageClassificationLearned",
	    "PerceiverForMaskedLM",
	    "PerceiverForMultimodalAutoencoding",
	    "PerceiverForOpticalFlow",
	    "PerceiverForSequenceClassification",
	    "PerceiverLayer",
	    "PerceiverModel",
	    "PerceiverPreTrainedModel",
	]


if TYPE_CHECKING:
	from .configuration_perceiver import PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP, PerceiverConfig, PerceiverOnnxConfig
	from .tokenization_perceiver import PerceiverTokenizer

	try:
		if not is_vision_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .feature_extraction_perceiver import PerceiverFeatureExtractor
		from .image_processing_perceiver import PerceiverImageProcessor

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_perceiver import (
		    PERCEIVER_PRETRAINED_MODEL_ARCHIVE_LIST,
		    PerceiverForImageClassificationConvProcessing,
		    PerceiverForImageClassificationFourier,
		    PerceiverForImageClassificationLearned,
		    PerceiverForMaskedLM,
		    PerceiverForMultimodalAutoencoding,
		    PerceiverForOpticalFlow,
		    PerceiverForSequenceClassification,
		    PerceiverLayer,
		    PerceiverModel,
		    PerceiverPreTrainedModel,
		)

else:
	import sys

	UpperCamelCase						:				Tuple             =      _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)









"""simple docstring"""


from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


UpperCamelCase						:				int             =      logging.get_logger(__name__)

UpperCamelCase						:				Optional[int]             =      {
    "google/bit-50": "https://huggingface.co/google/bit-50/resolve/main/config.json",
}



class 			lowerCamelCase__						(   UpperCAmelCase_							,    UpperCAmelCase_			):
						lowerCAmelCase       =     """bit"""
						lowerCAmelCase       =     ["""preactivation""", """bottleneck"""]
						lowerCAmelCase       =     ["""SAME""", """VALID"""]







						def __init__(							self   :    List[str]			,			_lowercase   :    int=3			,			_lowercase   :    List[str]=64			,			_lowercase   :    Optional[int]=[256, 512, 1_024, 2_048]			,			_lowercase   :    Optional[int]=[3, 4, 6, 3]			,			_lowercase   :    int="preactivation"			,			_lowercase   :    Union[str, Any]="relu"			,			_lowercase   :    List[Any]=None			,			_lowercase   :    Tuple=32			,			_lowercase   :    Optional[int]=0.0			,			_lowercase   :    Union[str, Any]=False			,			_lowercase   :    Dict=32			,			_lowercase   :    Union[str, Any]=1			,			_lowercase   :    List[Any]=None			,			_lowercase   :    Any=None			,			**_lowercase   :    str			,			):
								super().__init__(**_lowercase		)
								if layer_type not in self.layer_types:
										raise ValueError(f'layer_type={layer_type} is not one of {",".join(self.layer_types		)}'		)
								if global_padding is not None:
										if global_padding.upper() in self.supported_padding:
												A					       = global_padding.upper()
										else:
												raise ValueError(f'Padding strategy {global_padding} not supported'		)
								A					       = num_channels
								A					       = embedding_size
								A					       = hidden_sizes
								A					       = depths
								A					       = layer_type
								A					       = hidden_act
								A					       = global_padding
								A					       = num_groups
								A					       = drop_path_rate
								A					       = embedding_dynamic_padding
								A					       = output_stride
								A					       = width_factor

								A					       = ['stem'] + [f'stage{idx}' for idx in range(1			,			len(_lowercase		) + 1		)]
								A       , A					       = get_aligned_output_features_output_indices(
								    out_features=_lowercase			,			out_indices=_lowercase			,			stage_names=self.stage_names		)





