





"""simple docstring"""


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   __SCREAMING_SNAKE_CASE     (    _UpperCamelCase		,	_UpperCamelCase ):







  '''simple docstring'''


  SCREAMING_SNAKE_CASE__				:Tuple						  =       "focalnet"

  def __init__(		self :							int       , __a :							Dict=224       , __a :							Union[str, Any]=4       , __a :							Dict=3       , __a :							Any=96       , __a :							Any=False       , __a :							Tuple=[192, 384, 768, 768]       , __a :							List[Any]=[2, 2, 6, 2]       , __a :							int=[2, 2, 2, 2]       , __a :							int=[3, 3, 3, 3]       , __a :							List[Any]="gelu"       , __a :							Dict=4.0       , __a :							str=0.0       , __a :							List[Any]=0.1       , __a :							List[str]=False       , __a :							Union[str, Any]=1e-4       , __a :							Any=False       , __a :							Tuple=False       , __a :							Optional[Any]=False       , __a :							str=0.02       , __a :							List[str]=1e-5       , __a :							int=32       , __a :							Any=None       , __a :							List[str]=None       , **__a :							str       , )		->					Dict:
        super().__init__(**__a						)

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







"""simple docstring"""


from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding



class   __SCREAMING_SNAKE_CASE     (    _UpperCamelCase ):







  '''simple docstring'''


  SCREAMING_SNAKE_CASE__				:Optional[Any]						  =       ["image_processor", "tokenizer"]
  SCREAMING_SNAKE_CASE__				:Dict						  =       "AutoImageProcessor"
  SCREAMING_SNAKE_CASE__				:Optional[int]						  =       "AutoTokenizer"

  def __init__(		self :							Dict       , __a :							Tuple       , __a :							str						)		->					Optional[Any]:
        super().__init__(__a       , __a						)
        _UpperCamelCase   :						Tuple    =							self.image_processor

  def __call__(		self :							Tuple       , __a :							Tuple=None       , __a :							str=None       , __a :							Any=None       , **__a :							Optional[Any]						)		->					Union[str, Any]:

        if text is None and images is None:
              raise ValueError("You have to specify either text or images. Both cannot be none."						)

        if text is not None:
              _UpperCamelCase   :						List[str]    =							self.tokenizer(__a       , return_tensors=__a       , **__a						)

        if images is not None:
              _UpperCamelCase   :						str    =							self.image_processor(__a       , return_tensors=__a       , **__a						)

        if text is not None and images is not None:
              _UpperCamelCase   :						Optional[int]    =							image_features.pixel_values
              return encoding
        elif text is not None:
              return encoding
        else:
              return BatchEncoding(data=dict(**__a						)       , tensor_type=__a						)

  def  __SCREAMING_SNAKE_CASE					(		self :							Optional[int]       , *__a :							Optional[int]       , **__a :							Optional[int]						)		->					List[Any]:
        return self.tokenizer.batch_decode(*__a       , **__a						)

  def  __SCREAMING_SNAKE_CASE					(		self :							int       , *__a :							Any       , **__a :							List[Any]						)		->					Tuple:
        return self.tokenizer.decode(*__a       , **__a						)


  @property
  def  __SCREAMING_SNAKE_CASE					(		self :							str						)		->					Any:
        return ["input_ids", "attention_mask", "pixel_values"]
