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__   :
  
  
  
       '''simple docstring'''
  
  
  
  
       def __init__( self       :       Union[str, Any]	,      UpperCamelCase       :       Tuple	,      UpperCamelCase       :       Optional[Any]=13	,      UpperCamelCase       :       Optional[int]=7	,      UpperCamelCase       :       List[str]=True	,      UpperCamelCase       :       int=True	,      UpperCamelCase       :       int=True	,      UpperCamelCase       :       Tuple=True	,      UpperCamelCase       :       Tuple=99	,      UpperCamelCase       :       Tuple=32	,      UpperCamelCase       :       Any=5	,      UpperCamelCase       :       Optional[int]=4	,      UpperCamelCase       :       Optional[Any]=37	,      UpperCamelCase       :       List[Any]="gelu"	,      UpperCamelCase       :       Any=0.1	,      UpperCamelCase       :       List[Any]=0.1	,      UpperCamelCase       :       Tuple=5_12	,      UpperCamelCase       :       int=16	,      UpperCamelCase       :       int=2	,      UpperCamelCase       :       List[Any]=0.02	,      UpperCamelCase       :       Optional[int]=3	,      UpperCamelCase       :       List[str]=None	,      UpperCamelCase       :       List[Any]=20	,      UpperCamelCase       :       Dict=30	,      UpperCamelCase       :       Dict=2	,      UpperCamelCase       :       Optional[int]=2	,      UpperCamelCase       :       str=10	,      ):
  
  
  
  
  
              """simple docstring"""
  
  
  
              _lowercase					:				Union[str, Any]           =			parent
              _lowercase					:				Optional[Any]           =			batch_size
              _lowercase					:				Dict           =			seq_length
              _lowercase					:				int           =			is_training
              _lowercase					:				Optional[Any]           =			use_input_mask
              _lowercase					:				Dict           =			use_token_type_ids
              _lowercase					:				Dict           =			use_labels
              _lowercase					:				List[Any]           =			vocab_size
              _lowercase					:				str           =			hidden_size
              _lowercase					:				Tuple           =			num_hidden_layers
              _lowercase					:				Union[str, Any]           =			num_attention_heads
              _lowercase					:				Optional[int]           =			intermediate_size
              _lowercase					:				Tuple           =			hidden_act
              _lowercase					:				List[str]           =			hidden_dropout_prob
              _lowercase					:				Optional[Any]           =			attention_probs_dropout_prob
              _lowercase					:				Any           =			max_position_embeddings
              _lowercase					:				Dict           =			type_vocab_size
              _lowercase					:				List[str]           =			type_sequence_label_size
              _lowercase					:				Tuple           =			initializer_range
              _lowercase					:				Tuple           =			num_labels
              _lowercase					:				Dict           =			scope
              _lowercase					:				int           =			max_xpath_tag_unit_embeddings
              _lowercase					:				Optional[int]           =			max_xpath_subs_unit_embeddings
              _lowercase					:				Optional[Any]           =			tag_pad_id
              _lowercase					:				Union[str, Any]           =			subs_pad_id
              _lowercase					:				Dict           =			max_depth
  
  
  
  
       def   lowerCAmelCase_   ( self       :       List[Any]		):
  
  
  
  
  
              """simple docstring"""
  
  
  
              _lowercase					:				Tuple           =			ids_tensor([self.batch_size, self.seq_length]	,      self.vocab_size		)
  
              _lowercase					:				Dict           =			ids_tensor(
                  [self.batch_size, self.seq_length, self.max_depth]	,      self.max_xpath_tag_unit_embeddings		)
  
              _lowercase					:				Tuple           =			ids_tensor(
                  [self.batch_size, self.seq_length, self.max_depth]	,      self.max_xpath_subs_unit_embeddings		)
  
              _lowercase					:				Any           =			None
              if self.use_input_mask:
                     _lowercase					:				List[str]           =			ids_tensor([self.batch_size, self.seq_length]	,      vocab_size=2		)
  
              _lowercase					:				Tuple           =			None
              if self.use_token_type_ids:
                     _lowercase					:				List[Any]           =			ids_tensor([self.batch_size, self.seq_length]	,      self.type_vocab_size		)
  
              _lowercase					:				Optional[int]           =			None
              _lowercase					:				Dict           =			None
              if self.use_labels:
                     _lowercase					:				Optional[int]           =			ids_tensor([self.batch_size]	,      self.type_sequence_label_size		)
                     _lowercase					:				int           =			ids_tensor([self.batch_size, self.seq_length]	,      self.num_labels		)
  
              _lowercase					:				Optional[Any]           =			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       :       Dict		):
  
  
  
  
  
              """simple docstring"""
  
  
  
              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       :       Dict	,      UpperCamelCase       :       List[str]	,      UpperCamelCase       :       Union[str, Any]	,      UpperCamelCase       :       int	,      UpperCamelCase       :       str	,      UpperCamelCase       :       int	,      UpperCamelCase       :       int	,      UpperCamelCase       :       Union[str, Any]	,      UpperCamelCase       :       Optional[Any]	,      ):
  
  
  
  
  
              """simple docstring"""
  
  
  
              _lowercase					:				Optional[int]           =			MarkupLMModel(config=UpperCamelCase		)
              model.to(UpperCamelCase		)
              model.eval()
              print('''Configs:'''	,      model.config.tag_pad_id	,      model.config.subs_pad_id		)
              _lowercase					:				List[str]           =			model(UpperCamelCase	,      attention_mask=UpperCamelCase	,      token_type_ids=UpperCamelCase		)
              _lowercase					:				List[str]           =			model(UpperCamelCase	,      token_type_ids=UpperCamelCase		)
              _lowercase					:				List[Any]           =			model(UpperCamelCase		)
              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       :       int	,      UpperCamelCase       :       Tuple	,      UpperCamelCase       :       int	,      UpperCamelCase       :       Dict	,      UpperCamelCase       :       Tuple	,      UpperCamelCase       :       int	,      UpperCamelCase       :       Any	,      UpperCamelCase       :       Dict	,      UpperCamelCase       :       List[Any]	,      ):
  
  
  
  
  
              """simple docstring"""
  
  
  
              _lowercase					:				List[str]           =			self.num_labels
              _lowercase					:				Optional[int]           =			MarkupLMForSequenceClassification(UpperCamelCase		)
              model.to(UpperCamelCase		)
              model.eval()
              _lowercase					:				Union[str, Any]           =			model(
                  UpperCamelCase	,      xpath_tags_seq=UpperCamelCase	,      xpath_subs_seq=UpperCamelCase	,      attention_mask=UpperCamelCase	,      token_type_ids=UpperCamelCase	,      labels=UpperCamelCase	,      )
              self.parent.assertEqual(result.logits.shape	,      (self.batch_size, self.num_labels)		)
  
  
  
  
       def   lowerCAmelCase_   ( self       :       Tuple	,      UpperCamelCase       :       int	,      UpperCamelCase       :       Any	,      UpperCamelCase       :       int	,      UpperCamelCase       :       Optional[Any]	,      UpperCamelCase       :       Optional[int]	,      UpperCamelCase       :       Any	,      UpperCamelCase       :       Optional[int]	,      UpperCamelCase       :       Dict	,      ):
  
  
  
  
  
              """simple docstring"""
  
  
  
              _lowercase					:				Union[str, Any]           =			self.num_labels
              _lowercase					:				Optional[int]           =			MarkupLMForTokenClassification(config=UpperCamelCase		)
              model.to(UpperCamelCase		)
              model.eval()
              _lowercase					:				List[Any]           =			model(
                  UpperCamelCase	,      xpath_tags_seq=UpperCamelCase	,      xpath_subs_seq=UpperCamelCase	,      attention_mask=UpperCamelCase	,      token_type_ids=UpperCamelCase	,      labels=UpperCamelCase	,      )
              self.parent.assertEqual(result.logits.shape	,      (self.batch_size, self.seq_length, self.num_labels)		)
  
  
  
  
       def   lowerCAmelCase_   ( self       :       Any	,      UpperCamelCase       :       Tuple	,      UpperCamelCase       :       Any	,      UpperCamelCase       :       Any	,      UpperCamelCase       :       Union[str, Any]	,      UpperCamelCase       :       Optional[Any]	,      UpperCamelCase       :       int	,      UpperCamelCase       :       Any	,      UpperCamelCase       :       Optional[Any]	,      ):
  
  
  
  
  
              """simple docstring"""
  
  
  
              _lowercase					:				Any           =			MarkupLMForQuestionAnswering(config=UpperCamelCase		)
              model.to(UpperCamelCase		)
              model.eval()
              _lowercase					:				Dict           =			model(
                  UpperCamelCase	,      xpath_tags_seq=UpperCamelCase	,      xpath_subs_seq=UpperCamelCase	,      attention_mask=UpperCamelCase	,      token_type_ids=UpperCamelCase	,      start_positions=UpperCamelCase	,      end_positions=UpperCamelCase	,      )
              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       :       Optional[Any]		):
  
  
  
  
  
              """simple docstring"""
  
  
  
              _lowercase					:				Optional[Any]           =			self.prepare_config_and_inputs()
              (
                  (
                  _lowercase
              )       ,	(
                  _lowercase
              )       ,	(
                  _lowercase
              )       ,	(
                  _lowercase
              )       ,	(
                  _lowercase
              )       ,	(
                  _lowercase
              )       ,	(
                  _lowercase
              )       ,	(
                  _lowercase
              )       ,	
              )					:				List[str]           =			config_and_inputs
              _lowercase					:				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 						UpperCAmelCase__   (      A_      ,						A_      ,						unittest.TestCase		):
  
  
  
       '''simple docstring'''
       UpperCAmelCase_         =  (
           (
               MarkupLMModel,
               MarkupLMForSequenceClassification,
               MarkupLMForTokenClassification,
               MarkupLMForQuestionAnswering,
           )
           if is_torch_available()
           else None
       )
       UpperCAmelCase_         =  (
           {
               '''feature-extraction''': MarkupLMModel,
               '''question-answering''': MarkupLMForQuestionAnswering,
               '''text-classification''': MarkupLMForSequenceClassification,
               '''token-classification''': MarkupLMForTokenClassification,
               '''zero-shot''': MarkupLMForSequenceClassification,
           }
           if is_torch_available()
           else {}
       )
  
  
  
  
       def   lowerCAmelCase_   ( self       :       Union[str, Any]	,      UpperCamelCase       :       Optional[Any]	,      UpperCamelCase       :       str	,      UpperCamelCase       :       Union[str, Any]	,      UpperCamelCase       :       Optional[Any]	,      UpperCamelCase       :       Tuple		):
  
  
  
  
  
              """simple docstring"""
  
  
  
              return True
  
  
  
  
       def   lowerCAmelCase_   ( self       :       Union[str, Any]		):
  
  
  
  
  
              """simple docstring"""
  
  
  
              _lowercase					:				Optional[int]           =			MarkupLMModelTester(self		)
              _lowercase					:				str           =			ConfigTester(self	,      config_class=UpperCamelCase	,      hidden_size=37		)
  
  
  
  
       def   lowerCAmelCase_   ( self       :       Optional[int]		):
  
  
  
  
  
              """simple docstring"""
  
  
  
              self.config_tester.run_common_tests()
  
  
  
  
       def   lowerCAmelCase_   ( self       :       Optional[int]		):
  
  
  
  
  
              """simple docstring"""
  
  
  
              _lowercase					:				List[Any]           =			self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_model(*UpperCamelCase		)
  
  
  
  
       def   lowerCAmelCase_   ( self       :       Optional[int]		):
  
  
  
  
  
              """simple docstring"""
  
  
  
              _lowercase					:				Optional[int]           =			self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_for_sequence_classification(*UpperCamelCase		)
  
  
  
  
       def   lowerCAmelCase_   ( self       :       List[Any]		):
  
  
  
  
  
              """simple docstring"""
  
  
  
              _lowercase					:				Dict           =			self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_for_token_classification(*UpperCamelCase		)
  
  
  
  
       def   lowerCAmelCase_   ( self       :       Optional[Any]		):
  
  
  
  
  
              """simple docstring"""
  
  
  
              _lowercase					:				List[Any]           =			self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_for_question_answering(*UpperCamelCase		)
  
  
  
  
  def   UpperCamelCase__   (    )						->							Union[str, Any]:
  
  
  
  
         '''simple docstring'''
  
  
  
  
  
  
         _lowercase					:				List[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 						UpperCAmelCase__   (      unittest.TestCase		):
  
  
  
       '''simple docstring'''
  
  
  
  
       @cached_property
       def   lowerCAmelCase_   ( self       :       str		):
  
  
  
  
  
              """simple docstring"""
  
  
  
              _lowercase					:				Optional[Any]           =			MarkupLMFeatureExtractor()
              _lowercase					:				str           =			MarkupLMTokenizer.from_pretrained('''microsoft/markuplm-base'''		)
  
              return MarkupLMProcessor(UpperCamelCase	,      UpperCamelCase		)
  
  
  
  
       @slow
       def   lowerCAmelCase_   ( self       :       int		):
  
  
  
  
  
              """simple docstring"""
  
  
  
              _lowercase					:				Tuple           =			MarkupLMModel.from_pretrained('''microsoft/markuplm-base'''		).to(UpperCamelCase		)
  
              _lowercase					:				List[Any]           =			self.default_processor
  
              _lowercase					:				int           =			processor(prepare_html_string()	,      return_tensors='''pt'''		)
              _lowercase					:				Optional[int]           =			inputs.to(UpperCamelCase		)
  
              # forward pass
              with torch.no_grad():
                     _lowercase					:				Union[str, Any]           =			model(**UpperCamelCase		)
  
              # verify the last hidden states
              _lowercase					:				Optional[int]           =			torch.Size([1, 14, 7_68]		)
              self.assertEqual(outputs.last_hidden_state.shape	,      UpperCamelCase		)
  
              _lowercase					:				int           =			torch.tensor(
                  [[0.0675, -0.0052, 0.5001], [-0.2281, 0.0802, 0.2192], [-0.0583, -0.3311, 0.1185]]		).to(UpperCamelCase		)
  
              self.assertTrue(torch.allclose(outputs.last_hidden_state[0, :3, :3]	,      UpperCamelCase	,      atol=1E-4		)		)
style_context: 
  
  
  from typing import TYPE_CHECKING
  
  from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available
  
  
  UpperCamelCase__				       =			{
      'configuration_wav2vec2_conformer': [
          'WAV2VEC2_CONFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP',
          'Wav2Vec2ConformerConfig',
      ],
  }
  
  
  try:
     if not is_torch_available():
        raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
     pass
  else:
     UpperCamelCase__				       =			[
         'WAV2VEC2_CONFORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
         'Wav2Vec2ConformerForAudioFrameClassification',
         'Wav2Vec2ConformerForCTC',
         'Wav2Vec2ConformerForPreTraining',
         'Wav2Vec2ConformerForSequenceClassification',
         'Wav2Vec2ConformerForXVector',
         'Wav2Vec2ConformerModel',
         'Wav2Vec2ConformerPreTrainedModel',
     ]
  
  if TYPE_CHECKING:
     from .configuration_wavaveca_conformer import (
         WAV2VEC2_CONFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
         WavaVecaConformerConfig,
     )
  
     try:
        if not is_torch_available():
           raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
        pass
     else:
        from .modeling_wavaveca_conformer import (
            WAV2VEC2_CONFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
            WavaVecaConformerForAudioFrameClassification,
            WavaVecaConformerForCTC,
            WavaVecaConformerForPreTraining,
            WavaVecaConformerForSequenceClassification,
            WavaVecaConformerForXVector,
            WavaVecaConformerModel,
            WavaVecaConformerPreTrainedModel,
        )
  
  else:
     import sys
  
     UpperCamelCase__				       =			_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)