code: 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 					UpperCAmelCase_				:
  
  
  
  
      def __init__(					self  :   List[Any]      ,      lowerCAmelCase  :   Union[str, Any]      ,      lowerCAmelCase  :   Tuple=13      ,      lowerCAmelCase  :   int=7      ,      lowerCAmelCase  :   Union[str, Any]=True      ,      lowerCAmelCase  :   Union[str, Any]=True      ,      lowerCAmelCase  :   Optional[int]=True      ,      lowerCAmelCase  :   Any=True      ,      lowerCAmelCase  :   int=99      ,      lowerCAmelCase  :   Dict=32      ,      lowerCAmelCase  :   List[str]=5      ,      lowerCAmelCase  :   Dict=4      ,      lowerCAmelCase  :   Any=37      ,      lowerCAmelCase  :   Any="gelu"      ,      lowerCAmelCase  :   int=0.1      ,      lowerCAmelCase  :   Union[str, Any]=0.1      ,      lowerCAmelCase  :   List[Any]=512      ,      lowerCAmelCase  :   Union[str, Any]=16      ,      lowerCAmelCase  :   str=2      ,      lowerCAmelCase  :   Dict=0.02      ,      lowerCAmelCase  :   Optional[int]=3      ,      lowerCAmelCase  :   Union[str, Any]=None      ,      lowerCAmelCase  :   int=20      ,      lowerCAmelCase  :   Any=30      ,      lowerCAmelCase  :   Tuple=2      ,      lowerCAmelCase  :   Dict=2      ,      lowerCAmelCase  :   int=10      ,      )	-> List[str]:
        a__     		=     parent
        a__     		=     batch_size
        a__     		=     seq_length
        a__     		=     is_training
        a__     		=     use_input_mask
        a__     		=     use_token_type_ids
        a__     		=     use_labels
        a__     		=     vocab_size
        a__     		=     hidden_size
        a__     		=     num_hidden_layers
        a__     		=     num_attention_heads
        a__     		=     intermediate_size
        a__     		=     hidden_act
        a__     		=     hidden_dropout_prob
        a__     		=     attention_probs_dropout_prob
        a__     		=     max_position_embeddings
        a__     		=     type_vocab_size
        a__     		=     type_sequence_label_size
        a__     		=     initializer_range
        a__     		=     num_labels
        a__     		=     scope
        a__     		=     max_xpath_tag_unit_embeddings
        a__     		=     max_xpath_subs_unit_embeddings
        a__     		=     tag_pad_id
        a__     		=     subs_pad_id
        a__     		=     max_depth
  
  
  
  
      def 						__lowerCamelCase (					self  :   List[Any]   )	-> List[Any]:
        a__     		=     ids_tensor([self.batch_size, self.seq_length]      ,      self.vocab_size   )
  
        a__     		=     ids_tensor(
            [self.batch_size, self.seq_length, self.max_depth]      ,      self.max_xpath_tag_unit_embeddings   )
  
        a__     		=     ids_tensor(
            [self.batch_size, self.seq_length, self.max_depth]      ,      self.max_xpath_subs_unit_embeddings   )
  
        a__     		=     None
        if self.use_input_mask:
          a__     		=     ids_tensor([self.batch_size, self.seq_length]      ,      vocab_size=2   )
  
        a__     		=     None
        if self.use_token_type_ids:
          a__     		=     ids_tensor([self.batch_size, self.seq_length]      ,      self.type_vocab_size   )
  
        a__     		=     None
        a__     		=     None
        if self.use_labels:
          a__     		=     ids_tensor([self.batch_size]      ,      self.type_sequence_label_size   )
          a__     		=     ids_tensor([self.batch_size, self.seq_length]      ,      self.num_labels   )
  
        a__     		=     self.get_config()
  
        return (
            config,
            input_ids,
            xpath_tags_seq,
            xpath_subs_seq,
            token_type_ids,
            input_mask,
            sequence_labels,
            token_labels,
        )
  
  
  
  
      def 						__lowerCamelCase (					self  :   List[str]   )	-> Union[str, Any]:
        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 						__lowerCamelCase (					self  :   int      ,      lowerCAmelCase  :   Optional[int]      ,      lowerCAmelCase  :   Any      ,      lowerCAmelCase  :   str      ,      lowerCAmelCase  :   str      ,      lowerCAmelCase  :   Union[str, Any]      ,      lowerCAmelCase  :   str      ,      lowerCAmelCase  :   Union[str, Any]      ,      lowerCAmelCase  :   Any      ,      )	-> str:
        a__     		=     MarkupLMModel(config=lowerCAmelCase   )
        model.to(lowerCAmelCase   )
        model.eval()
        print("Configs:"      ,      model.config.tag_pad_id      ,      model.config.subs_pad_id   )
        a__     		=     model(lowerCAmelCase      ,      attention_mask=lowerCAmelCase      ,      token_type_ids=lowerCAmelCase   )
        a__     		=     model(lowerCAmelCase      ,      token_type_ids=lowerCAmelCase   )
        a__     		=     model(lowerCAmelCase   )
        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 						__lowerCamelCase (					self  :   Any      ,      lowerCAmelCase  :   int      ,      lowerCAmelCase  :   Any      ,      lowerCAmelCase  :   Optional[Any]      ,      lowerCAmelCase  :   Dict      ,      lowerCAmelCase  :   Union[str, Any]      ,      lowerCAmelCase  :   List[str]      ,      lowerCAmelCase  :   Optional[int]      ,      lowerCAmelCase  :   Tuple      ,      )	-> Optional[int]:
        a__     		=     self.num_labels
        a__     		=     MarkupLMForSequenceClassification(lowerCAmelCase   )
        model.to(lowerCAmelCase   )
        model.eval()
        a__     		=     model(
            lowerCAmelCase      ,      xpath_tags_seq=lowerCAmelCase      ,      xpath_subs_seq=lowerCAmelCase      ,      attention_mask=lowerCAmelCase      ,      token_type_ids=lowerCAmelCase      ,      labels=lowerCAmelCase      ,      )
        self.parent.assertEqual(result.logits.shape      ,      (self.batch_size, self.num_labels)   )
  
  
  
  
      def 						__lowerCamelCase (					self  :   Optional[Any]      ,      lowerCAmelCase  :   Dict      ,      lowerCAmelCase  :   List[str]      ,      lowerCAmelCase  :   Union[str, Any]      ,      lowerCAmelCase  :   List[Any]      ,      lowerCAmelCase  :   Union[str, Any]      ,      lowerCAmelCase  :   Any      ,      lowerCAmelCase  :   Optional[Any]      ,      lowerCAmelCase  :   List[str]      ,      )	-> Any:
        a__     		=     self.num_labels
        a__     		=     MarkupLMForTokenClassification(config=lowerCAmelCase   )
        model.to(lowerCAmelCase   )
        model.eval()
        a__     		=     model(
            lowerCAmelCase      ,      xpath_tags_seq=lowerCAmelCase      ,      xpath_subs_seq=lowerCAmelCase      ,      attention_mask=lowerCAmelCase      ,      token_type_ids=lowerCAmelCase      ,      labels=lowerCAmelCase      ,      )
        self.parent.assertEqual(result.logits.shape      ,      (self.batch_size, self.seq_length, self.num_labels)   )
  
  
  
  
      def 						__lowerCamelCase (					self  :   Optional[int]      ,      lowerCAmelCase  :   Union[str, Any]      ,      lowerCAmelCase  :   Optional[int]      ,      lowerCAmelCase  :   Any      ,      lowerCAmelCase  :   str      ,      lowerCAmelCase  :   str      ,      lowerCAmelCase  :   Optional[int]      ,      lowerCAmelCase  :   Tuple      ,      lowerCAmelCase  :   Union[str, Any]      ,      )	-> str:
        a__     		=     MarkupLMForQuestionAnswering(config=lowerCAmelCase   )
        model.to(lowerCAmelCase   )
        model.eval()
        a__     		=     model(
            lowerCAmelCase      ,      xpath_tags_seq=lowerCAmelCase      ,      xpath_subs_seq=lowerCAmelCase      ,      attention_mask=lowerCAmelCase      ,      token_type_ids=lowerCAmelCase      ,      start_positions=lowerCAmelCase      ,      end_positions=lowerCAmelCase      ,      )
        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 						__lowerCamelCase (					self  :   List[Any]   )	-> List[str]:
        a__     		=     self.prepare_config_and_inputs()
        (
            (
            a__
        )		,(
            a__
        )		,(
            a__
        )		,(
            a__
        )		,(
            a__
        )		,(
            a__
        )		,(
            a__
        )		,(
            a__
        )		,
        )     		=     config_and_inputs
        a__     		=     {
            "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 					UpperCAmelCase_				(							_a     ,     _a     ,     unittest.TestCase    ):
      UpperCAmelCase_			:       List[Any]						 =							(
          (
              MarkupLMModel,
              MarkupLMForSequenceClassification,
              MarkupLMForTokenClassification,
              MarkupLMForQuestionAnswering,
          )
          if is_torch_available()
          else None
      )
      UpperCAmelCase_			:       List[Any]						 =							(
          {
              'feature-extraction': MarkupLMModel,
              'question-answering': MarkupLMForQuestionAnswering,
              'text-classification': MarkupLMForSequenceClassification,
              'token-classification': MarkupLMForTokenClassification,
              'zero-shot': MarkupLMForSequenceClassification,
          }
          if is_torch_available()
          else {}
      )
  
  
  
  
      def 						__lowerCamelCase (					self  :   Dict      ,      lowerCAmelCase  :   Optional[Any]      ,      lowerCAmelCase  :   int      ,      lowerCAmelCase  :   List[Any]      ,      lowerCAmelCase  :   str      ,      lowerCAmelCase  :   Any   )	-> str:
        # ValueError: Nodes must be of type `List[str]` (single pretokenized example), or `List[List[str]]`
        # (batch of pretokenized examples).
        return True
  
  
  
  
      def 						__lowerCamelCase (					self  :   str   )	-> Union[str, Any]:
        a__     		=     MarkupLMModelTester(self   )
        a__     		=     ConfigTester(self      ,      config_class=lowerCAmelCase      ,      hidden_size=37   )
  
  
  
  
      def 						__lowerCamelCase (					self  :   int   )	-> Union[str, Any]:
        self.config_tester.run_common_tests()
  
  
  
  
      def 						__lowerCamelCase (					self  :   Optional[int]   )	-> str:
        a__     		=     self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_model(*lowerCAmelCase   )
  
  
  
  
      def 						__lowerCamelCase (					self  :   List[str]   )	-> Tuple:
        a__     		=     self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_sequence_classification(*lowerCAmelCase   )
  
  
  
  
      def 						__lowerCamelCase (					self  :   Dict   )	-> Optional[Any]:
        a__     		=     self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_token_classification(*lowerCAmelCase   )
  
  
  
  
      def 						__lowerCamelCase (					self  :   Optional[Any]   )	-> int:
        a__     		=     self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_question_answering(*lowerCAmelCase   )
  
  def 				__lowercase	(						)				->List[Any]:
  
    '''simple docstring'''
  
  
  
  
    a__     		=     "\n    <!DOCTYPE html>\n    <html>\n    <head>\n    <title>Page Title</title>\n    </head>\n    <body>\n\n    <h1>This is a Heading</h1>\n    <p>This is a paragraph.</p>\n\n    </body>\n    </html>\n    "
  
    return html_string
  
  
  
  
  
  
  
  @require_torch
  class 					UpperCAmelCase_				(							unittest.TestCase    ):
  
  
  
  
      @cached_property
      def 						__lowerCamelCase (					self  :   str   )	-> Optional[Any]:
        # TODO use from_pretrained here
        a__     		=     MarkupLMFeatureExtractor()
        a__     		=     MarkupLMTokenizer.from_pretrained("microsoft/markuplm-base"   )
  
        return MarkupLMProcessor(lowerCAmelCase      ,      lowerCAmelCase   )
  
  
  
  
      @slow
      def 						__lowerCamelCase (					self  :   str   )	-> Optional[Any]:
        a__     		=     MarkupLMModel.from_pretrained("microsoft/markuplm-base"   ).to(lowerCAmelCase   )
  
        a__     		=     self.default_processor
  
        a__     		=     processor(prepare_html_string()      ,      return_tensors="pt"   )
        a__     		=     inputs.to(lowerCAmelCase   )
  
        # forward pass
        with torch.no_grad():
          a__     		=     model(**lowerCAmelCase   )
  
        # verify the last hidden states
        a__     		=     torch.Size([1, 14, 768]   )
        self.assertEqual(outputs.last_hidden_state.shape      ,      lowerCAmelCase   )
  
        a__     		=     torch.tensor(
            [[0.0_675, -0.0_052, 0.5_001], [-0.2_281, 0.0_802, 0.2_192], [-0.0_583, -0.3_311, 0.1_185]]   ).to(lowerCAmelCase   )
  
        self.assertTrue(torch.allclose(outputs.last_hidden_state[0, :3, :3]      ,      lowerCAmelCase      ,      atol=1e-4   )   )
  
  
style_context: def 				__lowercase	(						lowerCamelCase__ ,				lowerCamelCase__					)				->Optional[int]:
  
    '''simple docstring'''
  
  
  
  
    sequence.append(lowerCamelCase__					)
  
    a__     		=     0
    while sequence[index] != target:
      index += 1
  
    sequence.pop()
  
    if index == len(lowerCamelCase__					):
      return None
  
    return index
  
  
  if __name__ == "__main__":
       _SCREAMING_SNAKE_CASE   						=    input("""Enter numbers separated by comma:\n""").strip()
       _SCREAMING_SNAKE_CASE   						=    [int(item) for item in user_input.split(""",""")]
  
       _SCREAMING_SNAKE_CASE   						=    input("""Enter a single number to be found in the list:\n""")
       _SCREAMING_SNAKE_CASE   						=    int(target_input)
       _SCREAMING_SNAKE_CASE   						=    sentinel_linear_search(sequence, target)
       if result is not None:
            print(F"""{target} found at positions: {result}""")
       else:
            print("""Not found""")
  
  