"""simple docstring"""



import json
from typing import List, Optional, Tuple

from tokenizers import pre_tokenizers, processors

from ...tokenization_utils_base import AddedToken, BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_mvp import MvpTokenizer


SCREAMING_SNAKE_CASE__:Any			=	logging.get_logger(__name__)


SCREAMING_SNAKE_CASE__:Optional[int]			=	{"""vocab_file""": """vocab.json""", """merges_file""": """merges.txt""", """tokenizer_file""": """tokenizer.json"""}

# See all MVP models at https://huggingface.co/models?filter=mvp
SCREAMING_SNAKE_CASE__:Tuple			=	{
    """vocab_file""": {
        """RUCAIBox/mvp""": """https://huggingface.co/RUCAIBox/mvp/resolve/main/vocab.json""",
    },
    """added_tokens.json""": {
        """RUCAIBox/mvp""": """https://huggingface.co/RUCAIBox/mvp/resolve/main/added_tokens.json""",
    },
    """merges_file""": {
        """RUCAIBox/mvp""": """https://huggingface.co/RUCAIBox/mvp/resolve/main/merges.txt""",
    },
    """tokenizer_file""": {
        """RUCAIBox/mvp""": """https://huggingface.co/RUCAIBox/mvp/resolve/main/tokenizer.json""",
    },
}

SCREAMING_SNAKE_CASE__:int			=	{
    """RUCAIBox/mvp""": 1024,
}






class 				snake_case__     (   snake_case_   ):
 _snake_case   :			Tuple           =		VOCAB_FILES_NAMES
 _snake_case   :			Union[str, Any]           =		PRETRAINED_VOCAB_FILES_MAP
 _snake_case   :			Optional[Any]           =		PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
 _snake_case   :			Any           =		["""input_ids""", """attention_mask"""]
 _snake_case   :			Tuple           =		MvpTokenizer


 def __init__(				self  ,						lowerCamelCase=None  ,						lowerCamelCase=None  ,						lowerCamelCase=None  ,						lowerCamelCase="replace"  ,						lowerCamelCase="<s>"  ,						lowerCamelCase="</s>"  ,						lowerCamelCase="</s>"  ,						lowerCamelCase="<s>"  ,						lowerCamelCase="<unk>"  ,						lowerCamelCase="<pad>"  ,						lowerCamelCase="<mask>"  ,						lowerCamelCase=False  ,						lowerCamelCase=True  ,						**lowerCamelCase  ,						):
        super().__init__(
            lowerCamelCase  ,						lowerCamelCase  ,						tokenizer_file=lowerCamelCase  ,						errors=lowerCamelCase  ,						bos_token=lowerCamelCase  ,						eos_token=lowerCamelCase  ,						sep_token=lowerCamelCase  ,						cls_token=lowerCamelCase  ,						unk_token=lowerCamelCase  ,						pad_token=lowerCamelCase  ,						mask_token=lowerCamelCase  ,						add_prefix_space=lowerCamelCase  ,						trim_offsets=lowerCamelCase  ,						**lowerCamelCase  ,						)

        __a     				=  json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__()		)
        if pre_tok_state.get("add_prefix_space"  ,						lowerCamelCase		) != add_prefix_space:
               __a     				=  getattr(lowerCamelCase  ,						pre_tok_state.pop("type"		)		)
               __a     				=  add_prefix_space
               __a     				=  pre_tok_class(**lowerCamelCase		)

        __a     				=  add_prefix_space

        # the pre_tokenizer is already updated in the GPT2TokenizerFast `__init__`
        __a     				=  "post_processor"
        __a     				=  getattr(self.backend_tokenizer  ,						lowerCamelCase  ,						lowerCamelCase		)
        if tokenizer_component_instance:
               __a     				=  json.loads(tokenizer_component_instance.__getstate__()		)

               # The lists 'sep' and 'cls' must be cased in tuples for the object `post_processor_class`
               if "sep" in state:
                      __a     				=  tuple(state["sep"]		)
               if "cls" in state:
                      __a     				=  tuple(state["cls"]		)

               __a     				=  False

               if state.get("add_prefix_space"  ,						lowerCamelCase		) != add_prefix_space:
                      __a     				=  add_prefix_space
                      __a     				=  True

               if state.get("trim_offsets"  ,						lowerCamelCase		) != trim_offsets:
                      __a     				=  trim_offsets
                      __a     				=  True

               if changes_to_apply:
                      __a     				=  getattr(lowerCamelCase  ,						state.pop("type"		)		)
                      __a     				=  component_class(**lowerCamelCase		)
                      setattr(self.backend_tokenizer  ,						lowerCamelCase  ,						lowerCamelCase		)


 @property
 def 		a__ (				self		):
        if self._mask_token is None:
               if self.verbose:
                      logger.error("Using mask_token, but it is not set yet."		)
               return None
        return str(self._mask_token		)


 @mask_token.setter
 def 		a__ (				self  ,						lowerCamelCase		):
        __a     				=  AddedToken(lowerCamelCase  ,						lstrip=lowerCamelCase  ,						rstrip=lowerCamelCase		) if isinstance(lowerCamelCase  ,						lowerCamelCase		) else value
        __a     				=  value


 def 		a__ (				self  ,						*lowerCamelCase  ,						**lowerCamelCase		):
        __a     				=  kwargs.get("is_split_into_words"  ,						lowerCamelCase		)

        if is_split_into_words and not self.add_prefix_space:
               raise ValueError(
                   F"You need to instantiate {self.__class__.__name__} with add_prefix_space=True "
                   "to use it with pretokenized inputs."		)

        return super()._batch_encode_plus(*lowerCamelCase  ,						**lowerCamelCase		)


 def 		a__ (				self  ,						*lowerCamelCase  ,						**lowerCamelCase		):
        __a     				=  kwargs.get("is_split_into_words"  ,						lowerCamelCase		)

        if is_split_into_words and not self.add_prefix_space:
               raise ValueError(
                   F"You need to instantiate {self.__class__.__name__} with add_prefix_space=True "
                   "to use it with pretokenized inputs."		)

        return super()._encode_plus(*lowerCamelCase  ,						**lowerCamelCase		)


 def 		a__ (				self  ,						lowerCamelCase  ,						lowerCamelCase = None		):
        __a     				=  self._tokenizer.model.save(lowerCamelCase  ,						name=lowerCamelCase		)
        return tuple(lowerCamelCase		)


 def 		a__ (				self  ,						lowerCamelCase  ,						lowerCamelCase=None		):
        __a     				=  [self.bos_token_id] + token_ids_a + [self.eos_token_id]
        if token_ids_a is None:
               return output

        return output + [self.eos_token_id] + token_ids_a + [self.eos_token_id]






 def 		a__ (				self  ,						lowerCamelCase  ,						lowerCamelCase = None		):
        __a     				=  [self.sep_token_id]
        __a     				=  [self.cls_token_id]

        if token_ids_a is None:
               return len(cls + token_ids_a + sep		) * [0]
        return len(cls + token_ids_a + sep + sep + token_ids_a + sep		) * [0]

"""simple docstring"""



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


SCREAMING_SNAKE_CASE__:List[str]			=	logging.get_logger(__name__)

SCREAMING_SNAKE_CASE__:int			=	{
    """microsoft/focalnet-tiny""": """https://huggingface.co/microsoft/focalnet-tiny/resolve/main/config.json""",
}






class 				snake_case__     (   snake_case_,		snake_case_   ):
 _snake_case   :			List[Any]           =		"""focalnet"""


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

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