






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


lowerCamelCase     :							Union[str, Any]    ={
    '''configuration_mask2former''': [
        '''MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''Mask2FormerConfig''',
    ],
}

try:
 if not is_vision_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase     :							List[str]    =['''Mask2FormerImageProcessor''']

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase     :							Any    =[
     '''MASK2FORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''Mask2FormerForUniversalSegmentation''',
     '''Mask2FormerModel''',
     '''Mask2FormerPreTrainedModel''',
 ]

if TYPE_CHECKING:
 from .configuration_maskaformer import MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, MaskaFormerConfig

 try:
  if not is_vision_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .image_processing_maskaformer import MaskaFormerImageProcessor

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_maskaformer import (
      MASK2FORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
      MaskaFormerForUniversalSegmentation,
      MaskaFormerModel,
      MaskaFormerPreTrainedModel,
  )


else:
 import sys

 lowerCamelCase     :							List[str]    =_LazyModule(__name__, globals()['''__file__'''], _import_structure)







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


lowerCamelCase     :							List[Any]    =logging.get_logger(__name__)

lowerCamelCase     :							Optional[Any]    ={
    '''google/bit-50''': '''https://huggingface.co/google/bit-50/resolve/main/config.json''',
}





class       __a  (   A__	,       A__	):
 _lowerCAmelCase	:	Union[str, Any]				=			'''bit'''
 _lowerCAmelCase	:	List[str]				=			['''preactivation''', '''bottleneck''']
 _lowerCAmelCase	:	Any				=			['''SAME''', '''VALID''']







 def __init__(		self :       str							,       SCREAMING_SNAKE_CASE :       Tuple=3							,       SCREAMING_SNAKE_CASE :       str=64							,       SCREAMING_SNAKE_CASE :       List[Any]=[2_56, 5_12, 10_24, 20_48]							,       SCREAMING_SNAKE_CASE :       Union[str, Any]=[3, 4, 6, 3]							,       SCREAMING_SNAKE_CASE :       str="preactivation"							,       SCREAMING_SNAKE_CASE :       Any="relu"							,       SCREAMING_SNAKE_CASE :       Dict=None							,       SCREAMING_SNAKE_CASE :       List[Any]=32							,       SCREAMING_SNAKE_CASE :       Tuple=0.0							,       SCREAMING_SNAKE_CASE :       Dict=False							,       SCREAMING_SNAKE_CASE :       int=32							,       SCREAMING_SNAKE_CASE :       str=1							,       SCREAMING_SNAKE_CASE :       List[str]=None							,       SCREAMING_SNAKE_CASE :       Optional[int]=None							,       **SCREAMING_SNAKE_CASE :       int							,       ):


      '''simple docstring'''






      super().__init__(**SCREAMING_SNAKE_CASE						)
      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:
                UpperCamelCase__      :       Any	    =  global_padding.upper()
           else:
                raise ValueError(F'Padding strategy {global_padding} not supported'						)
      UpperCamelCase__      :       Dict	    =  num_channels
      UpperCamelCase__      :       Dict	    =  embedding_size
      UpperCamelCase__      :       Tuple	    =  hidden_sizes
      UpperCamelCase__      :       Any	    =  depths
      UpperCamelCase__      :       Optional[int]	    =  layer_type
      UpperCamelCase__      :       int	    =  hidden_act
      UpperCamelCase__      :       str	    =  global_padding
      UpperCamelCase__      :       Any	    =  num_groups
      UpperCamelCase__      :       str	    =  drop_path_rate
      UpperCamelCase__      :       Optional[Any]	    =  embedding_dynamic_padding
      UpperCamelCase__      :       Tuple	    =  output_stride
      UpperCamelCase__      :       List[str]	    =  width_factor

      UpperCamelCase__      :       Any	    =  ["stem"] + [F'stage{idx}' for idx in range(1							,       len(SCREAMING_SNAKE_CASE						) + 1						)]
      UpperCamelCase__    ,					UpperCamelCase__      :       Union[str, Any]	    =  get_aligned_output_features_output_indices(
          out_features=SCREAMING_SNAKE_CASE							,       out_indices=SCREAMING_SNAKE_CASE							,       stage_names=self.stage_names						)