

"""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        _lowercase					(     UpperCAmelCase__   , UpperCAmelCase__     ):
     _lowerCamelCase     =       '''focalnet'''







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

      __magic_name__     =      image_size
      __magic_name__     =      patch_size
      __magic_name__     =      num_channels
      __magic_name__     =      embed_dim
      __magic_name__     =      use_conv_embed
      __magic_name__     =      hidden_sizes
      __magic_name__     =      depths
      __magic_name__     =      focal_levels
      __magic_name__     =      focal_windows
      __magic_name__     =      hidden_act
      __magic_name__     =      mlp_ratio
      __magic_name__     =      hidden_dropout_prob
      __magic_name__     =      drop_path_rate
      __magic_name__     =      use_layerscale
      __magic_name__     =      layerscale_value
      __magic_name__     =      use_post_layernorm
      __magic_name__     =      use_post_layernorm_in_modulation
      __magic_name__     =      normalize_modulator
      __magic_name__     =      initializer_range
      __magic_name__     =      layer_norm_eps
      __magic_name__     =      encoder_stride
      __magic_name__     =      ['''stem'''] + [f'''stage{idx}''' for idx in range(1 ,						len(self.depths       ) + 1       )]
      __magic_name__   ,						__magic_name__     =      get_aligned_output_features_output_indices(
          out_features=__lowerCAmelCase ,						out_indices=__lowerCAmelCase ,						stage_names=self.stage_names       )




"""simple docstring"""






import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device


if is_torch_available():
 from transformers import AutoModelForSeqaSeqLM, AutoTokenizer
@require_torch
@require_sentencepiece
@require_tokenizers
class        _lowercase					(     unittest.TestCase     ):







     @slow
     def 	lowerCAmelCase__    (      self       ):
      __magic_name__     =      AutoModelForSeqaSeqLM.from_pretrained('''google/mt5-small''' ,						return_dict=UpperCamelCase_       ).to(UpperCamelCase_       )
      __magic_name__     =      AutoTokenizer.from_pretrained('''google/mt5-small'''       )

      __magic_name__     =      tokenizer('''Hello there''' ,						return_tensors='''pt'''       ).input_ids
      __magic_name__     =      tokenizer('''Hi I am''' ,						return_tensors='''pt'''       ).input_ids

      __magic_name__     =      model(input_ids.to(UpperCamelCase_       ) ,						labels=labels.to(UpperCamelCase_       )       ).loss
      __magic_name__     =      -(labels.shape[-1] * loss.item())

      __magic_name__     =      -8_4.9_1_2_7
      self.assertTrue(abs(mtf_score - EXPECTED_SCORE       ) < 1E-4       )

