code: 
  
  
  import json
  import os
  from functools import lru_cache
  from typing import List, Optional, Tuple
  
  import regex as re
  
  from ...tokenization_utils import AddedToken, PreTrainedTokenizer
  from ...utils import logging
  
  
  SCREAMING_SNAKE_CASE__				:    List[str]         =    logging.get_logger(__name__)
  
  
  SCREAMING_SNAKE_CASE__				:    str         =    {'vocab_file': 'vocab.json', 'merges_file': 'merges.txt'}
  
  # See all MVP models at https://huggingface.co/models?filter=mvp
  SCREAMING_SNAKE_CASE__				:    str         =    {
      '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',
      },
  }
  
  SCREAMING_SNAKE_CASE__				:    List[Any]         =    {
      'RUCAIBox/mvp': 1_024,
  }
  
  
  
  
  @lru_cache()
  def       a__						(		):
    _UpperCAmelCase		:       List[str]       =    (
        list(range(ord("""!"""    )	,      ord("""~"""    ) + 1    )    ) + list(range(ord("""¡"""    )	,      ord("""¬"""    ) + 1    )    ) + list(range(ord("""®"""    )	,      ord("""ÿ"""    ) + 1    )    )
    )
    _UpperCAmelCase		:       List[str]       =    bs[:]
    _UpperCAmelCase		:       Union[str, Any]       =    0
    for b in range(2**8    ):
      if b not in bs:
        bs.append(UpperCamelCase__    )
        cs.append(2**8 + n    )
        n += 1
    _UpperCAmelCase		:       Dict       =    [chr(UpperCamelCase__    ) for n in cs]
    return dict(zip(UpperCamelCase__	,      UpperCamelCase__    )    )
  
  
  
  
  def       a__						(		snake_case__				:       List[str]    ):
    _UpperCAmelCase		:       int       =    set()
    _UpperCAmelCase		:       Optional[int]       =    word[0]
    for char in word[1:]:
      pairs.add((prev_char, char)    )
      _UpperCAmelCase		:       Union[str, Any]       =    char
    return pairs
  
  
  
  
  
  class 		_SCREAMING_SNAKE_CASE    (	A    ):
       __SCREAMING_SNAKE_CASE    				=						VOCAB_FILES_NAMES
       __SCREAMING_SNAKE_CASE    				=						PRETRAINED_VOCAB_FILES_MAP
       __SCREAMING_SNAKE_CASE    				=						PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
       __SCREAMING_SNAKE_CASE    				=						['''input_ids''', '''attention_mask''']
  
  
       def __init__(     self       ,				A_       ,				A_       ,				A_="replace"       ,				A_="<s>"       ,				A_="</s>"       ,				A_="</s>"       ,				A_="<s>"       ,				A_="<unk>"       ,				A_="<pad>"       ,				A_="<mask>"       ,				A_=False       ,				**A_       ,				):
         _UpperCAmelCase		:       Any       =    AddedToken(A_       ,				lstrip=A_       ,				rstrip=A_						) if isinstance(A_       ,				A_						) else bos_token
         _UpperCAmelCase		:       str       =    AddedToken(A_       ,				lstrip=A_       ,				rstrip=A_						) if isinstance(A_       ,				A_						) else eos_token
         _UpperCAmelCase		:       str       =    AddedToken(A_       ,				lstrip=A_       ,				rstrip=A_						) if isinstance(A_       ,				A_						) else sep_token
         _UpperCAmelCase		:       Optional[int]       =    AddedToken(A_       ,				lstrip=A_       ,				rstrip=A_						) if isinstance(A_       ,				A_						) else cls_token
         _UpperCAmelCase		:       Optional[int]       =    AddedToken(A_       ,				lstrip=A_       ,				rstrip=A_						) if isinstance(A_       ,				A_						) else unk_token
         _UpperCAmelCase		:       Optional[int]       =    AddedToken(A_       ,				lstrip=A_       ,				rstrip=A_						) if isinstance(A_       ,				A_						) else pad_token
  
         # Mask token behave like a normal word, i.e. include the space before it
         _UpperCAmelCase		:       Optional[int]       =    AddedToken(A_       ,				lstrip=A_       ,				rstrip=A_						) if isinstance(A_       ,				A_						) else mask_token
  
         super().__init__(
             errors=A_       ,				bos_token=A_       ,				eos_token=A_       ,				unk_token=A_       ,				sep_token=A_       ,				cls_token=A_       ,				pad_token=A_       ,				mask_token=A_       ,				add_prefix_space=A_       ,				**A_       ,				)
         with open(A_       ,				encoding="""utf-8"""						) as vocab_handle:
           _UpperCAmelCase		:       int       =    json.load(A_						)
         _UpperCAmelCase		:       Dict       =    {v: k for k, v in self.encoder.items()}
         _UpperCAmelCase		:       List[str]       =    errors  # how to handle errors in decoding
         _UpperCAmelCase		:       Any       =    bytes_to_unicode()
         _UpperCAmelCase		:       List[Any]       =    {v: k for k, v in self.byte_encoder.items()}
         with open(A_       ,				encoding="""utf-8"""						) as merges_handle:
           _UpperCAmelCase		:       Tuple       =    merges_handle.read().split("""\n"""						)[1:-1]
         _UpperCAmelCase		:       List[str]       =    [tuple(merge.split()						) for merge in bpe_merges]
         _UpperCAmelCase		:       Optional[Any]       =    dict(zip(A_       ,				range(len(A_						)						)						)						)
         _UpperCAmelCase		:       Tuple       =    {}
         _UpperCAmelCase		:       List[str]       =    add_prefix_space
  
         # Should have added re.IGNORECASE so BPE merges can happen for capitalized versions of contractions
         _UpperCAmelCase		:       Dict       =    re.compile(r"""\'s|\'t|\'re|\'ve|\'m|\'ll|\'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+"""						)
  
  
       @property
       def 					__snake_case(     self						):
         return len(self.encoder						)
  
  
       def 					__snake_case(     self						):
         return dict(self.encoder       ,				**self.added_tokens_encoder						)
  
  
       def 					__snake_case(     self       ,				A_						):
         if token in self.cache:
           return self.cache[token]
         _UpperCAmelCase		:       Optional[Any]       =    tuple(A_						)
         _UpperCAmelCase		:       Optional[int]       =    get_pairs(A_						)
  
         if not pairs:
           return token
  
         while True:
           _UpperCAmelCase		:       Dict       =    min(A_       ,				key=lambda A_						: self.bpe_ranks.get(A_       ,				float("""inf"""						)						)						)
           if bigram not in self.bpe_ranks:
             break
           _UpperCAmelCase		:       Any       =    bigram
           _UpperCAmelCase		:       Tuple       =    []
           _UpperCAmelCase		:       Optional[Any]       =    0
           while i < len(A_						):
             try:
               _UpperCAmelCase		:       int       =    word.index(A_       ,				A_						)
             except ValueError:
               new_word.extend(word[i:]						)
               break
             else:
               new_word.extend(word[i:j]						)
               _UpperCAmelCase		:       Union[str, Any]       =    j
  
             if word[i] == first and i < len(A_						) - 1 and word[i + 1] == second:
               new_word.append(first + second						)
               i += 2
             else:
               new_word.append(word[i]						)
               i += 1
           _UpperCAmelCase		:       Tuple       =    tuple(A_						)
           _UpperCAmelCase		:       Dict       =    new_word
           if len(A_						) == 1:
             break
           else:
             _UpperCAmelCase		:       Any       =    get_pairs(A_						)
         _UpperCAmelCase		:       List[Any]       =    ''' '''.join(A_						)
         _UpperCAmelCase		:       Optional[Any]       =    word
         return word
  
  
       def 					__snake_case(     self       ,				A_						):
         _UpperCAmelCase		:       List[str]       =    []
         for token in re.findall(self.pat       ,				A_						):
           _UpperCAmelCase		:       int       =    ''''''.join(
               self.byte_encoder[b] for b in token.encode("""utf-8"""						)						)  # Maps all our bytes to unicode strings, avoiding control tokens of the BPE (spaces in our case)
           bpe_tokens.extend(bpe_token for bpe_token in self.bpe(A_						).split(""" """						)						)
         return bpe_tokens
  
  
       def 					__snake_case(     self       ,				A_						):
         return self.encoder.get(A_       ,				self.encoder.get(self.unk_token						)						)
  
  
       def 					__snake_case(     self       ,				A_						):
         return self.decoder.get(A_						)
  
  
       def 					__snake_case(     self       ,				A_						):
         _UpperCAmelCase		:       Optional[int]       =    ''''''.join(A_						)
         _UpperCAmelCase		:       Union[str, Any]       =    bytearray([self.byte_decoder[c] for c in text]						).decode("""utf-8"""       ,				errors=self.errors						)
         return text
  
  
       def 					__snake_case(     self       ,				A_       ,				A_ = None						):
         if not os.path.isdir(A_						):
           logger.error(F'''Vocabulary path ({save_directory}) should be a directory'''						)
           return
         _UpperCAmelCase		:       List[str]       =    os.path.join(
             A_       ,				(filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab_file"""]						)
         _UpperCAmelCase		:       Any       =    os.path.join(
             A_       ,				(filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""merges_file"""]						)
  
         with open(A_       ,				"""w"""       ,				encoding="""utf-8"""						) as f:
           f.write(json.dumps(self.encoder       ,				indent=2       ,				sort_keys=A_       ,				ensure_ascii=A_						) + """\n"""						)
  
         _UpperCAmelCase		:       Optional[Any]       =    0
         with open(A_       ,				"""w"""       ,				encoding="""utf-8"""						) as writer:
           writer.write("""#version: 0.2\n"""						)
           for bpe_tokens, token_index in sorted(self.bpe_ranks.items()       ,				key=lambda A_						: kv[1]						):
             if index != token_index:
               logger.warning(
                   F'''Saving vocabulary to {merge_file}: BPE merge indices are not consecutive.'''
                   """ Please check that the tokenizer is not corrupted!"""						)
               _UpperCAmelCase		:       List[Any]       =    token_index
             writer.write(""" """.join(A_						) + """\n"""						)
             index += 1
  
         return vocab_file, merge_file
  
  
       def 					__snake_case(     self       ,				A_       ,				A_ = None						):
         if token_ids_a is None:
           return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
         _UpperCAmelCase		:       Optional[int]       =    [self.cls_token_id]
         _UpperCAmelCase		:       Dict       =    [self.sep_token_id]
         return cls + token_ids_a + sep + sep + token_ids_a + sep
  
  
       def 					__snake_case(     self       ,				A_       ,				A_ = None       ,				A_ = False						):
         if already_has_special_tokens:
           return super().get_special_tokens_mask(
               token_ids_a=A_       ,				token_ids_a=A_       ,				already_has_special_tokens=A_						)
  
         if token_ids_a is None:
           return [1] + ([0] * len(A_						)) + [1]
         return [1] + ([0] * len(A_						)) + [1, 1] + ([0] * len(A_						)) + [1]
  
  
       def 					__snake_case(     self       ,				A_       ,				A_ = None						):
         _UpperCAmelCase		:       str       =    [self.sep_token_id]
         _UpperCAmelCase		:       Union[str, Any]       =    [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]
  
  
  
  
       def 					__snake_case(     self       ,				A_       ,				A_=False       ,				**A_						):
         _UpperCAmelCase		:       str       =    kwargs.pop("""add_prefix_space"""       ,				self.add_prefix_space						)
         if (is_split_into_words or add_prefix_space) and (len(A_						) > 0 and not text[0].isspace()):
           _UpperCAmelCase		:       Tuple       =    ''' ''' + text
         return (text, kwargs)
  
  
  
  
  
  
style_context: 
  
  
  import unittest
  
  from transformers import MarkupLMConfig, is_torch_available
  from transformers.testing_utils import require_torch, slow, torch_device
  from transformers.utils import cached_property
  
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, ids_tensor
  from ...test_pipeline_mixin import PipelineTesterMixin
  
  
  if is_torch_available():
   import torch
  
   from transformers import (
       MarkupLMForQuestionAnswering,
       MarkupLMForSequenceClassification,
       MarkupLMForTokenClassification,
       MarkupLMModel,
   )
  
  # TODO check dependencies
  from transformers import MarkupLMFeatureExtractor, MarkupLMProcessor, MarkupLMTokenizer
  
  
  class 		_SCREAMING_SNAKE_CASE    :
  
  
       def __init__(     self       ,				A_       ,				A_=13       ,				A_=7       ,				A_=True       ,				A_=True       ,				A_=True       ,				A_=True       ,				A_=99       ,				A_=32       ,				A_=5       ,				A_=4       ,				A_=37       ,				A_="gelu"       ,				A_=0.1       ,				A_=0.1       ,				A_=5_12       ,				A_=16       ,				A_=2       ,				A_=0.0_2       ,				A_=3       ,				A_=None       ,				A_=20       ,				A_=30       ,				A_=2       ,				A_=2       ,				A_=10       ,				):
         _UpperCAmelCase		:       str       =    parent
         _UpperCAmelCase		:       Dict       =    batch_size
         _UpperCAmelCase		:       Optional[int]       =    seq_length
         _UpperCAmelCase		:       Union[str, Any]       =    is_training
         _UpperCAmelCase		:       Tuple       =    use_input_mask
         _UpperCAmelCase		:       Dict       =    use_token_type_ids
         _UpperCAmelCase		:       Dict       =    use_labels
         _UpperCAmelCase		:       Optional[int]       =    vocab_size
         _UpperCAmelCase		:       List[str]       =    hidden_size
         _UpperCAmelCase		:       Tuple       =    num_hidden_layers
         _UpperCAmelCase		:       Tuple       =    num_attention_heads
         _UpperCAmelCase		:       Optional[int]       =    intermediate_size
         _UpperCAmelCase		:       str       =    hidden_act
         _UpperCAmelCase		:       Optional[Any]       =    hidden_dropout_prob
         _UpperCAmelCase		:       List[str]       =    attention_probs_dropout_prob
         _UpperCAmelCase		:       Union[str, Any]       =    max_position_embeddings
         _UpperCAmelCase		:       List[Any]       =    type_vocab_size
         _UpperCAmelCase		:       Union[str, Any]       =    type_sequence_label_size
         _UpperCAmelCase		:       List[Any]       =    initializer_range
         _UpperCAmelCase		:       Union[str, Any]       =    num_labels
         _UpperCAmelCase		:       Any       =    scope
         _UpperCAmelCase		:       List[str]       =    max_xpath_tag_unit_embeddings
         _UpperCAmelCase		:       Tuple       =    max_xpath_subs_unit_embeddings
         _UpperCAmelCase		:       Optional[Any]       =    tag_pad_id
         _UpperCAmelCase		:       Union[str, Any]       =    subs_pad_id
         _UpperCAmelCase		:       Optional[int]       =    max_depth
  
  
       def 					__snake_case(     self						):
         _UpperCAmelCase		:       Dict       =    ids_tensor([self.batch_size, self.seq_length]       ,				self.vocab_size						)
  
         _UpperCAmelCase		:       List[str]       =    ids_tensor(
             [self.batch_size, self.seq_length, self.max_depth]       ,				self.max_xpath_tag_unit_embeddings						)
  
         _UpperCAmelCase		:       Tuple       =    ids_tensor(
             [self.batch_size, self.seq_length, self.max_depth]       ,				self.max_xpath_subs_unit_embeddings						)
  
         _UpperCAmelCase		:       int       =    None
         if self.use_input_mask:
           _UpperCAmelCase		:       Any       =    ids_tensor([self.batch_size, self.seq_length]       ,				vocab_size=2						)
  
         _UpperCAmelCase		:       Tuple       =    None
         if self.use_token_type_ids:
           _UpperCAmelCase		:       Dict       =    ids_tensor([self.batch_size, self.seq_length]       ,				self.type_vocab_size						)
  
         _UpperCAmelCase		:       str       =    None
         _UpperCAmelCase		:       Union[str, Any]       =    None
         if self.use_labels:
           _UpperCAmelCase		:       int       =    ids_tensor([self.batch_size]       ,				self.type_sequence_label_size						)
           _UpperCAmelCase		:       int       =    ids_tensor([self.batch_size, self.seq_length]       ,				self.num_labels						)
  
         _UpperCAmelCase		:       List[Any]       =    self.get_config()
  
         return (
             config,
             input_ids,
             xpath_tags_seq,
             xpath_subs_seq,
             token_type_ids,
             input_mask,
             sequence_labels,
             token_labels,
         )
  
  
       def 					__snake_case(     self						):
         return MarkupLMConfig(
             vocab_size=self.vocab_size       ,				hidden_size=self.hidden_size       ,				num_hidden_layers=self.num_hidden_layers       ,				num_attention_heads=self.num_attention_heads       ,				intermediate_size=self.intermediate_size       ,				hidden_act=self.hidden_act       ,				hidden_dropout_prob=self.hidden_dropout_prob       ,				attention_probs_dropout_prob=self.attention_probs_dropout_prob       ,				max_position_embeddings=self.max_position_embeddings       ,				type_vocab_size=self.type_vocab_size       ,				initializer_range=self.initializer_range       ,				max_xpath_tag_unit_embeddings=self.max_xpath_tag_unit_embeddings       ,				max_xpath_subs_unit_embeddings=self.max_xpath_subs_unit_embeddings       ,				tag_pad_id=self.tag_pad_id       ,				subs_pad_id=self.subs_pad_id       ,				max_depth=self.max_depth       ,				)
  
  
       def 					__snake_case(     self       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_       ,				):
         _UpperCAmelCase		:       Tuple       =    MarkupLMModel(config=A_						)
         model.to(A_						)
         model.eval()
         print("""Configs:"""       ,				model.config.tag_pad_id       ,				model.config.subs_pad_id						)
         _UpperCAmelCase		:       List[Any]       =    model(A_       ,				attention_mask=A_       ,				token_type_ids=A_						)
         _UpperCAmelCase		:       Tuple       =    model(A_       ,				token_type_ids=A_						)
         _UpperCAmelCase		:       Union[str, Any]       =    model(A_						)
         self.parent.assertEqual(result.last_hidden_state.shape       ,				(self.batch_size, self.seq_length, self.hidden_size)						)
         self.parent.assertEqual(result.pooler_output.shape       ,				(self.batch_size, self.hidden_size)						)
  
  
       def 					__snake_case(     self       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_       ,				):
         _UpperCAmelCase		:       Optional[int]       =    self.num_labels
         _UpperCAmelCase		:       List[Any]       =    MarkupLMForSequenceClassification(A_						)
         model.to(A_						)
         model.eval()
         _UpperCAmelCase		:       Any       =    model(
             A_       ,				xpath_tags_seq=A_       ,				xpath_subs_seq=A_       ,				attention_mask=A_       ,				token_type_ids=A_       ,				labels=A_       ,				)
         self.parent.assertEqual(result.logits.shape       ,				(self.batch_size, self.num_labels)						)
  
  
       def 					__snake_case(     self       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_       ,				):
         _UpperCAmelCase		:       List[Any]       =    self.num_labels
         _UpperCAmelCase		:       Any       =    MarkupLMForTokenClassification(config=A_						)
         model.to(A_						)
         model.eval()
         _UpperCAmelCase		:       Tuple       =    model(
             A_       ,				xpath_tags_seq=A_       ,				xpath_subs_seq=A_       ,				attention_mask=A_       ,				token_type_ids=A_       ,				labels=A_       ,				)
         self.parent.assertEqual(result.logits.shape       ,				(self.batch_size, self.seq_length, self.num_labels)						)
  
  
       def 					__snake_case(     self       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_       ,				):
         _UpperCAmelCase		:       List[Any]       =    MarkupLMForQuestionAnswering(config=A_						)
         model.to(A_						)
         model.eval()
         _UpperCAmelCase		:       List[Any]       =    model(
             A_       ,				xpath_tags_seq=A_       ,				xpath_subs_seq=A_       ,				attention_mask=A_       ,				token_type_ids=A_       ,				start_positions=A_       ,				end_positions=A_       ,				)
         self.parent.assertEqual(result.start_logits.shape       ,				(self.batch_size, self.seq_length)						)
         self.parent.assertEqual(result.end_logits.shape       ,				(self.batch_size, self.seq_length)						)
  
  
  
  
       def 					__snake_case(     self						):
         _UpperCAmelCase		:       Union[str, Any]       =    self.prepare_config_and_inputs()
         (
             (
             _UpperCAmelCase
         ),(
             _UpperCAmelCase
         ),(
             _UpperCAmelCase
         ),(
             _UpperCAmelCase
         ),(
             _UpperCAmelCase
         ),(
             _UpperCAmelCase
         ),(
             _UpperCAmelCase
         ),(
             _UpperCAmelCase
         ),
         )		:       List[str]       =    config_and_inputs
         _UpperCAmelCase		:       Optional[Any]       =    {
             """input_ids""": input_ids,
             """xpath_tags_seq""": xpath_tags_seq,
             """xpath_subs_seq""": xpath_subs_seq,
             """token_type_ids""": token_type_ids,
             """attention_mask""": input_mask,
         }
         return config, inputs_dict
  
  
  @require_torch
  class 		_SCREAMING_SNAKE_CASE    (	A       ,  A       ,  unittest.TestCase    ):
       __SCREAMING_SNAKE_CASE    				=						(
           (
               MarkupLMModel,
               MarkupLMForSequenceClassification,
               MarkupLMForTokenClassification,
               MarkupLMForQuestionAnswering,
           )
           if is_torch_available()
           else None
       )
       __SCREAMING_SNAKE_CASE    				=						(
           {
               '''feature-extraction''': MarkupLMModel,
               '''question-answering''': MarkupLMForQuestionAnswering,
               '''text-classification''': MarkupLMForSequenceClassification,
               '''token-classification''': MarkupLMForTokenClassification,
               '''zero-shot''': MarkupLMForSequenceClassification,
           }
           if is_torch_available()
           else {}
       )
  
  
       def 					__snake_case(     self       ,				A_       ,				A_       ,				A_       ,				A_       ,				A_						):
         # ValueError: Nodes must be of type `List[str]` (single pretokenized example), or `List[List[str]]`
         # (batch of pretokenized examples).
         return True
  
  
       def 					__snake_case(     self						):
         _UpperCAmelCase		:       Union[str, Any]       =    MarkupLMModelTester(self						)
         _UpperCAmelCase		:       str       =    ConfigTester(self       ,				config_class=A_       ,				hidden_size=37						)
  
  
       def 					__snake_case(     self						):
         self.config_tester.run_common_tests()
  
  
       def 					__snake_case(     self						):
         _UpperCAmelCase		:       List[Any]       =    self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_model(*A_						)
  
  
       def 					__snake_case(     self						):
         _UpperCAmelCase		:       Optional[int]       =    self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_sequence_classification(*A_						)
  
  
       def 					__snake_case(     self						):
         _UpperCAmelCase		:       Union[str, Any]       =    self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_token_classification(*A_						)
  
  
  
  
       def 					__snake_case(     self						):
         _UpperCAmelCase		:       Any       =    self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_question_answering(*A_						)
  
  
  
  
  def       a__						(		):
    _UpperCAmelCase		:       Any       =    """
      <!DOCTYPE html>
      <html>
      <head>
      <title>Page Title</title>
      </head>
      <body>
  
      <h1>This is a Heading</h1>
      <p>This is a paragraph.</p>
  
      </body>
      </html>
      """
  
    return html_string
  
  
  
  
  
  @require_torch
  class 		_SCREAMING_SNAKE_CASE    (	unittest.TestCase    ):
  
  
       @cached_property
       def 					__snake_case(     self						):
         # TODO use from_pretrained here
         _UpperCAmelCase		:       int       =    MarkupLMFeatureExtractor()
         _UpperCAmelCase		:       int       =    MarkupLMTokenizer.from_pretrained("""microsoft/markuplm-base"""						)
  
         return MarkupLMProcessor(A_       ,				A_						)
  
  
  
  
       @slow
       def 					__snake_case(     self						):
         _UpperCAmelCase		:       List[Any]       =    MarkupLMModel.from_pretrained("""microsoft/markuplm-base"""						).to(A_						)
  
         _UpperCAmelCase		:       Optional[Any]       =    self.default_processor
  
         _UpperCAmelCase		:       str       =    processor(prepare_html_string()       ,				return_tensors="""pt"""						)
         _UpperCAmelCase		:       List[str]       =    inputs.to(A_						)
  
         # forward pass
         with torch.no_grad():
           _UpperCAmelCase		:       Optional[Any]       =    model(**A_						)
  
         # verify the last hidden states
         _UpperCAmelCase		:       Tuple       =    torch.Size([1, 14, 7_68]						)
         self.assertEqual(outputs.last_hidden_state.shape       ,				A_						)
  
         _UpperCAmelCase		:       List[Any]       =    torch.tensor(
             [[0.0_6_7_5, -0.0_0_5_2, 0.5_0_0_1], [-0.2_2_8_1, 0.0_8_0_2, 0.2_1_9_2], [-0.0_5_8_3, -0.3_3_1_1, 0.1_1_8_5]]						).to(A_						)
  
         self.assertTrue(torch.allclose(outputs.last_hidden_state[0, :3, :3]       ,				A_       ,				atol=1e-4						)						)
  
  
  
  
  
  