



from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__lowerCamelCase         =			{
    '''configuration_roberta''': ['''ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''RobertaConfig''', '''RobertaOnnxConfig'''],
    '''tokenization_roberta''': ['''RobertaTokenizer'''],
}

try:
   if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __lowerCamelCase         =			['''RobertaTokenizerFast''']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __lowerCamelCase         =			[
       '''ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST''',
       '''RobertaForCausalLM''',
       '''RobertaForMaskedLM''',
       '''RobertaForMultipleChoice''',
       '''RobertaForQuestionAnswering''',
       '''RobertaForSequenceClassification''',
       '''RobertaForTokenClassification''',
       '''RobertaModel''',
       '''RobertaPreTrainedModel''',
   ]

try:
   if not is_tf_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __lowerCamelCase         =			[
       '''TF_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST''',
       '''TFRobertaForCausalLM''',
       '''TFRobertaForMaskedLM''',
       '''TFRobertaForMultipleChoice''',
       '''TFRobertaForQuestionAnswering''',
       '''TFRobertaForSequenceClassification''',
       '''TFRobertaForTokenClassification''',
       '''TFRobertaMainLayer''',
       '''TFRobertaModel''',
       '''TFRobertaPreTrainedModel''',
   ]

try:
   if not is_flax_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __lowerCamelCase         =			[
       '''FlaxRobertaForCausalLM''',
       '''FlaxRobertaForMaskedLM''',
       '''FlaxRobertaForMultipleChoice''',
       '''FlaxRobertaForQuestionAnswering''',
       '''FlaxRobertaForSequenceClassification''',
       '''FlaxRobertaForTokenClassification''',
       '''FlaxRobertaModel''',
       '''FlaxRobertaPreTrainedModel''',
   ]


if TYPE_CHECKING:
   from .configuration_roberta import ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP, RobertaConfig, RobertaOnnxConfig
   from .tokenization_roberta import RobertaTokenizer

   try:
      if not is_tokenizers_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_roberta_fast import RobertaTokenizerFast

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_roberta import (
          ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
          RobertaForCausalLM,
          RobertaForMaskedLM,
          RobertaForMultipleChoice,
          RobertaForQuestionAnswering,
          RobertaForSequenceClassification,
          RobertaForTokenClassification,
          RobertaModel,
          RobertaPreTrainedModel,
      )

   try:
      if not is_tf_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_tf_roberta import (
          TF_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
          TFRobertaForCausalLM,
          TFRobertaForMaskedLM,
          TFRobertaForMultipleChoice,
          TFRobertaForQuestionAnswering,
          TFRobertaForSequenceClassification,
          TFRobertaForTokenClassification,
          TFRobertaMainLayer,
          TFRobertaModel,
          TFRobertaPreTrainedModel,
      )

   try:
      if not is_flax_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_flax_roberta import (
          FlaxRobertaForCausalLM,
          FlaxRobertaForMaskedLM,
          FlaxRobertaForMultipleChoice,
          FlaxRobertaForQuestionAnswering,
          FlaxRobertaForSequenceClassification,
          FlaxRobertaForTokenClassification,
          FlaxRobertaModel,
          FlaxRobertaPreTrainedModel,
      )

else:
   import sys

   __lowerCamelCase         =			_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)





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


__lowerCamelCase         =			logging.get_logger(__name__)

__lowerCamelCase         =			{
    '''microsoft/focalnet-tiny''': '''https://huggingface.co/microsoft/focalnet-tiny/resolve/main/config.json''',
}


class   snake_case_ (lowercase__ , lowercase__  ):




       """simple docstring"""






       _lowerCamelCase			    =				"""focalnet"""



       def __init__(     self     ,lowercase=224     ,lowercase=4     ,lowercase=3     ,lowercase=96     ,lowercase=False     ,lowercase=[192, 384, 768, 768]     ,lowercase=[2, 2, 6, 2]     ,lowercase=[2, 2, 2, 2]     ,lowercase=[3, 3, 3, 3]     ,lowercase="gelu"     ,lowercase=4.0     ,lowercase=0.0     ,lowercase=0.1     ,lowercase=False     ,lowercase=1E-4     ,lowercase=False     ,lowercase=False     ,lowercase=False     ,lowercase=0.02     ,lowercase=1E-5     ,lowercase=32     ,lowercase=None     ,lowercase=None     ,**lowercase     ,):

             """simple docstring"""





             super().__init__(**lowercase)

             UpperCAmelCase_  :	int				      =		image_size
             UpperCAmelCase_  :	Optional[Any]				      =		patch_size
             UpperCAmelCase_  :	Dict				      =		num_channels
             UpperCAmelCase_  :	Dict				      =		embed_dim
             UpperCAmelCase_  :	Optional[int]				      =		use_conv_embed
             UpperCAmelCase_  :	int				      =		hidden_sizes
             UpperCAmelCase_  :	Optional[int]				      =		depths
             UpperCAmelCase_  :	Optional[Any]				      =		focal_levels
             UpperCAmelCase_  :	Tuple				      =		focal_windows
             UpperCAmelCase_  :	int				      =		hidden_act
             UpperCAmelCase_  :	Any				      =		mlp_ratio
             UpperCAmelCase_  :	List[Any]				      =		hidden_dropout_prob
             UpperCAmelCase_  :	Tuple				      =		drop_path_rate
             UpperCAmelCase_  :	List[str]				      =		use_layerscale
             UpperCAmelCase_  :	List[str]				      =		layerscale_value
             UpperCAmelCase_  :	List[str]				      =		use_post_layernorm
             UpperCAmelCase_  :	Dict				      =		use_post_layernorm_in_modulation
             UpperCAmelCase_  :	int				      =		normalize_modulator
             UpperCAmelCase_  :	Dict				      =		initializer_range
             UpperCAmelCase_  :	str				      =		layer_norm_eps
             UpperCAmelCase_  :	Union[str, Any]				      =		encoder_stride
             UpperCAmelCase_  :	str				      =		["stem"] + [F"""stage{idx}""" for idx in range(1     ,len(self.depths) + 1)]
             UpperCAmelCase_      ,      UpperCAmelCase_  :	Any				      =		get_aligned_output_features_output_indices(
                 out_features=lowercase     ,out_indices=lowercase     ,stage_names=self.stage_names)
