




import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_bert import BertTokenizer


lowercase__				:      Tuple	   = logging.get_logger(__name__)

lowercase__				:      int	   = {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"}

lowercase__				:      Dict	   = {
    "vocab_file": {
        "bert-base-uncased": "https://huggingface.co/bert-base-uncased/resolve/main/vocab.txt",
        "bert-large-uncased": "https://huggingface.co/bert-large-uncased/resolve/main/vocab.txt",
        "bert-base-cased": "https://huggingface.co/bert-base-cased/resolve/main/vocab.txt",
        "bert-large-cased": "https://huggingface.co/bert-large-cased/resolve/main/vocab.txt",
        "bert-base-multilingual-uncased": (
            "https://huggingface.co/bert-base-multilingual-uncased/resolve/main/vocab.txt"
        ),
        "bert-base-multilingual-cased": "https://huggingface.co/bert-base-multilingual-cased/resolve/main/vocab.txt",
        "bert-base-chinese": "https://huggingface.co/bert-base-chinese/resolve/main/vocab.txt",
        "bert-base-german-cased": "https://huggingface.co/bert-base-german-cased/resolve/main/vocab.txt",
        "bert-large-uncased-whole-word-masking": (
            "https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/vocab.txt"
        ),
        "bert-large-cased-whole-word-masking": (
            "https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/vocab.txt"
        ),
        "bert-large-uncased-whole-word-masking-finetuned-squad": (
            "https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/vocab.txt"
        ),
        "bert-large-cased-whole-word-masking-finetuned-squad": (
            "https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/vocab.txt"
        ),
        "bert-base-cased-finetuned-mrpc": (
            "https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/vocab.txt"
        ),
        "bert-base-german-dbmdz-cased": "https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/vocab.txt",
        "bert-base-german-dbmdz-uncased": (
            "https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/vocab.txt"
        ),
        "TurkuNLP/bert-base-finnish-cased-v1": (
            "https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/vocab.txt"
        ),
        "TurkuNLP/bert-base-finnish-uncased-v1": (
            "https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/vocab.txt"
        ),
        "wietsedv/bert-base-dutch-cased": (
            "https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/vocab.txt"
        ),
    },
    "tokenizer_file": {
        "bert-base-uncased": "https://huggingface.co/bert-base-uncased/resolve/main/tokenizer.json",
        "bert-large-uncased": "https://huggingface.co/bert-large-uncased/resolve/main/tokenizer.json",
        "bert-base-cased": "https://huggingface.co/bert-base-cased/resolve/main/tokenizer.json",
        "bert-large-cased": "https://huggingface.co/bert-large-cased/resolve/main/tokenizer.json",
        "bert-base-multilingual-uncased": (
            "https://huggingface.co/bert-base-multilingual-uncased/resolve/main/tokenizer.json"
        ),
        "bert-base-multilingual-cased": (
            "https://huggingface.co/bert-base-multilingual-cased/resolve/main/tokenizer.json"
        ),
        "bert-base-chinese": "https://huggingface.co/bert-base-chinese/resolve/main/tokenizer.json",
        "bert-base-german-cased": "https://huggingface.co/bert-base-german-cased/resolve/main/tokenizer.json",
        "bert-large-uncased-whole-word-masking": (
            "https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/tokenizer.json"
        ),
        "bert-large-cased-whole-word-masking": (
            "https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/tokenizer.json"
        ),
        "bert-large-uncased-whole-word-masking-finetuned-squad": (
            "https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/tokenizer.json"
        ),
        "bert-large-cased-whole-word-masking-finetuned-squad": (
            "https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/tokenizer.json"
        ),
        "bert-base-cased-finetuned-mrpc": (
            "https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/tokenizer.json"
        ),
        "bert-base-german-dbmdz-cased": (
            "https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/tokenizer.json"
        ),
        "bert-base-german-dbmdz-uncased": (
            "https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/tokenizer.json"
        ),
        "TurkuNLP/bert-base-finnish-cased-v1": (
            "https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/tokenizer.json"
        ),
        "TurkuNLP/bert-base-finnish-uncased-v1": (
            "https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/tokenizer.json"
        ),
        "wietsedv/bert-base-dutch-cased": (
            "https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/tokenizer.json"
        ),
    },
}

lowercase__				:      Tuple	   = {
    "bert-base-uncased": 512,
    "bert-large-uncased": 512,
    "bert-base-cased": 512,
    "bert-large-cased": 512,
    "bert-base-multilingual-uncased": 512,
    "bert-base-multilingual-cased": 512,
    "bert-base-chinese": 512,
    "bert-base-german-cased": 512,
    "bert-large-uncased-whole-word-masking": 512,
    "bert-large-cased-whole-word-masking": 512,
    "bert-large-uncased-whole-word-masking-finetuned-squad": 512,
    "bert-large-cased-whole-word-masking-finetuned-squad": 512,
    "bert-base-cased-finetuned-mrpc": 512,
    "bert-base-german-dbmdz-cased": 512,
    "bert-base-german-dbmdz-uncased": 512,
    "TurkuNLP/bert-base-finnish-cased-v1": 512,
    "TurkuNLP/bert-base-finnish-uncased-v1": 512,
    "wietsedv/bert-base-dutch-cased": 512,
}

lowercase__				:      Dict	   = {
    "bert-base-uncased": {"do_lower_case": True},
    "bert-large-uncased": {"do_lower_case": True},
    "bert-base-cased": {"do_lower_case": False},
    "bert-large-cased": {"do_lower_case": False},
    "bert-base-multilingual-uncased": {"do_lower_case": True},
    "bert-base-multilingual-cased": {"do_lower_case": False},
    "bert-base-chinese": {"do_lower_case": False},
    "bert-base-german-cased": {"do_lower_case": False},
    "bert-large-uncased-whole-word-masking": {"do_lower_case": True},
    "bert-large-cased-whole-word-masking": {"do_lower_case": False},
    "bert-large-uncased-whole-word-masking-finetuned-squad": {"do_lower_case": True},
    "bert-large-cased-whole-word-masking-finetuned-squad": {"do_lower_case": False},
    "bert-base-cased-finetuned-mrpc": {"do_lower_case": False},
    "bert-base-german-dbmdz-cased": {"do_lower_case": False},
    "bert-base-german-dbmdz-uncased": {"do_lower_case": True},
    "TurkuNLP/bert-base-finnish-cased-v1": {"do_lower_case": False},
    "TurkuNLP/bert-base-finnish-uncased-v1": {"do_lower_case": True},
    "wietsedv/bert-base-dutch-cased": {"do_lower_case": False},
}




class       a__	( UpperCamelCase__				):
     a		:      Optional[Any]		 =     VOCAB_FILES_NAMES
     a		:      List[str]		 =     PRETRAINED_VOCAB_FILES_MAP
     a		:      Union[str, Any]		 =     PRETRAINED_INIT_CONFIGURATION
     a		:      Optional[Any]		 =     PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
     a		:      Dict		 =     BertTokenizer







     def __init__(     self  ,		A=None  ,		A=None  ,		A=True  ,		A="[UNK]"  ,		A="[SEP]"  ,		A="[PAD]"  ,		A="[CLS]"  ,		A="[MASK]"  ,		A=True  ,		A=None  ,		**A  ,		)  ->   Dict:



          '''simple docstring'''



          super().__init__(
              A  ,		tokenizer_file=A  ,		do_lower_case=A  ,		unk_token=A  ,		sep_token=A  ,		pad_token=A  ,		cls_token=A  ,		mask_token=A  ,		tokenize_chinese_chars=A  ,		strip_accents=A  ,		**A  ,		)

          a     =				json.loads(self.backend_tokenizer.normalizer.__getstate__()			)
          if (
              normalizer_state.get("lowercase"  ,		A			) != do_lower_case
              or normalizer_state.get("strip_accents"  ,		A			) != strip_accents
              or normalizer_state.get("handle_chinese_chars"  ,		A			) != tokenize_chinese_chars
          ):
               a     =				getattr(A  ,		normalizer_state.pop("type"			)			)
               a     =				do_lower_case
               a     =				strip_accents
               a     =				tokenize_chinese_chars
               a     =				normalizer_class(**A			)

          a     =				do_lower_case







     def       lowerCAmelCase_    (     self  ,		A  ,		A=None			)  ->   Optional[int]:



          '''simple docstring'''



          a     =				[self.cls_token_id] + token_ids_a + [self.sep_token_id]

          if token_ids_a:
               output += token_ids_a + [self.sep_token_id]

          return output







     def       lowerCAmelCase_    (     self  ,		A  ,		A = None			)  ->   List[int]:



          '''simple docstring'''



          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			) * [0] + len(token_ids_a + sep			) * [1]







     def       lowerCAmelCase_    (     self  ,		A  ,		A = None			)  ->   Tuple[str]:



          '''simple docstring'''



          a     =				self._tokenizer.model.save(A  ,		name=A			)
          return tuple(A			)







from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
from ..auto import CONFIG_MAPPING


lowercase__				:      Optional[Any]	   = logging.get_logger(__name__)

lowercase__				:      str	   = {
    "microsoft/table-transformer-detection": (
        "https://huggingface.co/microsoft/table-transformer-detection/resolve/main/config.json"
    ),
}




class       a__	( UpperCamelCase__				):
     a		:      Optional[int]		 =     """table-transformer"""
     a		:      Tuple		 =     ["""past_key_values"""]
     a		:      int		 =     {
         """hidden_size""": """d_model""",
         """num_attention_heads""": """encoder_attention_heads""",
     }







     def __init__(     self  ,		A=True  ,		A=None  ,		A=3  ,		A=100  ,		A=6  ,		A=2048  ,		A=8  ,		A=6  ,		A=2048  ,		A=8  ,		A=0.0  ,		A=0.0  ,		A=True  ,		A="relu"  ,		A=256  ,		A=0.1  ,		A=0.0  ,		A=0.0  ,		A=0.0_2  ,		A=1.0  ,		A=False  ,		A="sine"  ,		A="resnet50"  ,		A=True  ,		A=False  ,		A=1  ,		A=5  ,		A=2  ,		A=1  ,		A=1  ,		A=5  ,		A=2  ,		A=0.1  ,		**A  ,		)  ->   List[str]:



          '''simple docstring'''



          if backbone_config is not None and use_timm_backbone:
               raise ValueError("You can't specify both `backbone_config` and `use_timm_backbone`."			)

          if not use_timm_backbone:
               if backbone_config is None:
                    logger.info("`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone."			)
                    a     =				CONFIG_MAPPING["resnet"](out_features=["stage4"]			)
               elif isinstance(A  ,		A			):
                    a     =				backbone_config.get("model_type"			)
                    a     =				CONFIG_MAPPING[backbone_model_type]
                    a     =				config_class.from_dict(A			)
               # set timm attributes to None
               a  ,				a  ,				a     =				None, None, None

          a     =				use_timm_backbone
          a     =				backbone_config
          a     =				num_channels
          a     =				num_queries
          a     =				d_model
          a     =				encoder_ffn_dim
          a     =				encoder_layers
          a     =				encoder_attention_heads
          a     =				decoder_ffn_dim
          a     =				decoder_layers
          a     =				decoder_attention_heads
          a     =				dropout
          a     =				attention_dropout
          a     =				activation_dropout
          a     =				activation_function
          a     =				init_std
          a     =				init_xavier_std
          a     =				encoder_layerdrop
          a     =				decoder_layerdrop
          a     =				encoder_layers
          a     =				auxiliary_loss
          a     =				position_embedding_type
          a     =				backbone
          a     =				use_pretrained_backbone
          a     =				dilation
          # Hungarian matcher
          a     =				class_cost
          a     =				bbox_cost
          a     =				giou_cost
          # Loss coefficients
          a     =				mask_loss_coefficient
          a     =				dice_loss_coefficient
          a     =				bbox_loss_coefficient
          a     =				giou_loss_coefficient
          a     =				eos_coefficient
          super().__init__(is_encoder_decoder=A  ,		**A			)







     @property
     def       lowerCAmelCase_    (     self			)  ->   int:



          '''simple docstring'''



          return self.encoder_attention_heads







     @property
     def       lowerCAmelCase_    (     self			)  ->   int:



          '''simple docstring'''



          return self.d_model







class       a__	( UpperCamelCase__				):
     a		:      Any		 =     version.parse("""1.11"""				)







     @property
     def       lowerCAmelCase_    (     self			)  ->   Mapping[str, Mapping[int, str]]:



          '''simple docstring'''



          return OrderedDict(
              [
                  ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
                  ("pixel_mask", {0: "batch"}),
              ]			)







     @property
     def       lowerCAmelCase_    (     self			)  ->   float:



          '''simple docstring'''



          return 1e-5







     @property
     def       lowerCAmelCase_    (     self			)  ->   int:



          '''simple docstring'''



          return 12

