

import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging


_lowerCamelCase							=logging.get_logger(__name__)

_lowerCamelCase							={
    'facebook/sam-vit-huge': 'https://huggingface.co/facebook/sam-vit-huge/resolve/main/config.json',
    'facebook/sam-vit-large': 'https://huggingface.co/facebook/sam-vit-large/resolve/main/config.json',
    'facebook/sam-vit-base': 'https://huggingface.co/facebook/sam-vit-base/resolve/main/config.json',
}



class 						a_			(				__A	):



      """simple docstring"""







      def __init__( self	:				Union[str, Any]     ,snake_case	:				Tuple=256     ,snake_case	:				Any=1024     ,snake_case	:				Union[str, Any]=16     ,snake_case	:				str=16     ,snake_case	:				List[str]=4     ,snake_case	:				Union[str, Any]="gelu"     ,snake_case	:				Tuple=1e-6     ,**snake_case	:				Dict     ,):
           super().__init__(**_lowerCamelCase							)
           SCREAMING_SNAKE_CASE 		=hidden_size
           SCREAMING_SNAKE_CASE 		=image_size
           SCREAMING_SNAKE_CASE 		=patch_size
           SCREAMING_SNAKE_CASE 		=image_size // patch_size
           SCREAMING_SNAKE_CASE 		=mask_input_channels
           SCREAMING_SNAKE_CASE 		=num_point_embeddings
           SCREAMING_SNAKE_CASE 		=hidden_act
           SCREAMING_SNAKE_CASE 		=layer_norm_eps







class 						a_			(				__A	):



      """simple docstring"""







      def __init__( self	:				Optional[Any]     ,snake_case	:				Any=256     ,snake_case	:				Union[str, Any]="relu"     ,snake_case	:				Optional[Any]=2048     ,snake_case	:				Optional[Any]=2     ,snake_case	:				int=8     ,snake_case	:				Union[str, Any]=2     ,snake_case	:				Union[str, Any]=3     ,snake_case	:				Optional[int]=3     ,snake_case	:				List[str]=256     ,snake_case	:				Optional[int]=1e-6     ,**snake_case	:				Optional[int]     ,):
           super().__init__(**_lowerCamelCase							)
           SCREAMING_SNAKE_CASE 		=hidden_size
           SCREAMING_SNAKE_CASE 		=hidden_act
           SCREAMING_SNAKE_CASE 		=mlp_dim
           SCREAMING_SNAKE_CASE 		=num_hidden_layers
           SCREAMING_SNAKE_CASE 		=num_attention_heads
           SCREAMING_SNAKE_CASE 		=attention_downsample_rate
           SCREAMING_SNAKE_CASE 		=num_multimask_outputs
           SCREAMING_SNAKE_CASE 		=iou_head_depth
           SCREAMING_SNAKE_CASE 		=iou_head_hidden_dim
           SCREAMING_SNAKE_CASE 		=layer_norm_eps







class 						a_			(				__A	):



      """simple docstring"""







      def __init__( self	:				Dict     ,snake_case	:				Dict=768     ,snake_case	:				str=256     ,snake_case	:				Tuple=12     ,snake_case	:				Optional[Any]=12     ,snake_case	:				Optional[Any]=3     ,snake_case	:				str=1024     ,snake_case	:				List[Any]=16     ,snake_case	:				List[Any]="gelu"     ,snake_case	:				int=1e-06     ,snake_case	:				str=0.0     ,snake_case	:				Optional[int]=1e-10     ,snake_case	:				List[str]=True     ,snake_case	:				int=4.0     ,snake_case	:				Tuple=True     ,snake_case	:				int=True     ,snake_case	:				Any=14     ,snake_case	:				List[str]=[2, 5, 8, 11]     ,snake_case	:				str=128     ,snake_case	:				Optional[int]=None     ,**snake_case	:				Optional[int]     ,):
           super().__init__(**_lowerCamelCase							)

           SCREAMING_SNAKE_CASE 		=hidden_size
           SCREAMING_SNAKE_CASE 		=output_channels
           SCREAMING_SNAKE_CASE 		=num_hidden_layers
           SCREAMING_SNAKE_CASE 		=num_attention_heads
           SCREAMING_SNAKE_CASE 		=num_channels
           SCREAMING_SNAKE_CASE 		=image_size
           SCREAMING_SNAKE_CASE 		=patch_size
           SCREAMING_SNAKE_CASE 		=hidden_act
           SCREAMING_SNAKE_CASE 		=layer_norm_eps
           SCREAMING_SNAKE_CASE 		=attention_dropout
           SCREAMING_SNAKE_CASE 		=initializer_range
           SCREAMING_SNAKE_CASE 		=qkv_bias
           SCREAMING_SNAKE_CASE 		=mlp_ratio
           SCREAMING_SNAKE_CASE 		=use_abs_pos
           SCREAMING_SNAKE_CASE 		=use_rel_pos
           SCREAMING_SNAKE_CASE 		=window_size
           SCREAMING_SNAKE_CASE 		=global_attn_indexes
           SCREAMING_SNAKE_CASE 		=num_pos_feats
           SCREAMING_SNAKE_CASE 		=int(hidden_size * mlp_ratio							) if mlp_dim is None else mlp_dim







class 						a_			(				__A	):



      """simple docstring"""







      __UpperCAmelCase     						= 'sam'
      __UpperCAmelCase     						= True
      def __init__( self	:				List[Any]     ,snake_case	:				Optional[int]=None     ,snake_case	:				Optional[int]=None     ,snake_case	:				int=None     ,snake_case	:				List[str]=0.02     ,**snake_case	:				int     ,):
           super().__init__(**_lowerCamelCase							)
           SCREAMING_SNAKE_CASE 		=vision_config if vision_config is not None else {}
           SCREAMING_SNAKE_CASE 		=prompt_encoder_config if prompt_encoder_config is not None else {}
           SCREAMING_SNAKE_CASE 		=mask_decoder_config if mask_decoder_config is not None else {}

           if isinstance(_lowerCamelCase     ,_lowerCamelCase							):
                SCREAMING_SNAKE_CASE 		=vision_config.to_dict()
           if isinstance(_lowerCamelCase     ,_lowerCamelCase							):
                SCREAMING_SNAKE_CASE 		=prompt_encoder_config.to_dict()
           if isinstance(_lowerCamelCase     ,_lowerCamelCase							):
                SCREAMING_SNAKE_CASE 		=mask_decoder_config.to_dict()

           SCREAMING_SNAKE_CASE 		=SamVisionConfig(**_lowerCamelCase							)
           SCREAMING_SNAKE_CASE 		=SamPromptEncoderConfig(**_lowerCamelCase							)
           SCREAMING_SNAKE_CASE 		=SamMaskDecoderConfig(**_lowerCamelCase							)
           SCREAMING_SNAKE_CASE 		=initializer_range


      def 			_lowerCAmelCase	( self	:				List[str]							):
           SCREAMING_SNAKE_CASE 		=copy.deepcopy(self.__dict__							)
           SCREAMING_SNAKE_CASE 		=self.vision_config.to_dict()
           SCREAMING_SNAKE_CASE 		=self.prompt_encoder_config.to_dict()
           SCREAMING_SNAKE_CASE 		=self.mask_decoder_config.to_dict()
           SCREAMING_SNAKE_CASE 		=self.__class__.model_type
           return output






'''simple docstring'''





from typing import TYPE_CHECKING

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


UpperCamelCase__    :     List[Any]			  =   {
    'configuration_layoutlm': ['LAYOUTLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LayoutLMConfig', 'LayoutLMOnnxConfig'],
    'tokenization_layoutlm': ['LayoutLMTokenizer'],
}

try:
  if not is_tokenizers_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCamelCase__    :     Any			  =   ['LayoutLMTokenizerFast']

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCamelCase__    :     Optional[Any]			  =   [
      'LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST',
      'LayoutLMForMaskedLM',
      'LayoutLMForSequenceClassification',
      'LayoutLMForTokenClassification',
      'LayoutLMForQuestionAnswering',
      'LayoutLMModel',
      'LayoutLMPreTrainedModel',
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCamelCase__    :     str			  =   [
      'TF_LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST',
      'TFLayoutLMForMaskedLM',
      'TFLayoutLMForSequenceClassification',
      'TFLayoutLMForTokenClassification',
      'TFLayoutLMForQuestionAnswering',
      'TFLayoutLMMainLayer',
      'TFLayoutLMModel',
      'TFLayoutLMPreTrainedModel',
  ]


if TYPE_CHECKING:
  from .configuration_layoutlm import LAYOUTLM_PRETRAINED_CONFIG_ARCHIVE_MAP, LayoutLMConfig, LayoutLMOnnxConfig
  from .tokenization_layoutlm import LayoutLMTokenizer

  try:
    if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_layoutlm_fast import LayoutLMTokenizerFast

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_layoutlm import (
        LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST,
        LayoutLMForMaskedLM,
        LayoutLMForQuestionAnswering,
        LayoutLMForSequenceClassification,
        LayoutLMForTokenClassification,
        LayoutLMModel,
        LayoutLMPreTrainedModel,
    )
  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_layoutlm import (
        TF_LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFLayoutLMForMaskedLM,
        TFLayoutLMForQuestionAnswering,
        TFLayoutLMForSequenceClassification,
        TFLayoutLMForTokenClassification,
        TFLayoutLMMainLayer,
        TFLayoutLMModel,
        TFLayoutLMPreTrainedModel,
    )

else:
  import sys

  UpperCamelCase__    :     List[str]			  =   _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)
