"""simple docstring"""







from typing import Dict, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import (
    center_crop,
    convert_to_rgb,
    get_resize_output_image_size,
    normalize,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    OPENAI_CLIP_MEAN,
    OPENAI_CLIP_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


SCREAMING_SNAKE_CASE						=    logging.get_logger(__name__)


if is_vision_available():
						import PIL



class 			_lowerCamelCase      (lowercase__  ):
				_snake_case  =	["pixel_values"]







				def __init__(			self     :							Union[str, Any]      ,       lowerCamelCase_     :							bool = True      ,       lowerCamelCase_     :							Dict[str, int] = None      ,       lowerCamelCase_     :							PILImageResampling = PILImageResampling.BICUBIC      ,       lowerCamelCase_     :							bool = True      ,       lowerCamelCase_     :							Dict[str, int] = None      ,       lowerCamelCase_     :							bool = True      ,       lowerCamelCase_     :							Union[int, float] = 1 / 2_5_5      ,       lowerCamelCase_     :							bool = True      ,       lowerCamelCase_     :							Optional[Union[float, List[float]]] = None      ,       lowerCamelCase_     :							Optional[Union[float, List[float]]] = None      ,       lowerCamelCase_     :							bool = True      ,       **lowerCamelCase_     :							Optional[int]      ,       ):

					"""simple docstring"""






					super().__init__(**__lowerCamelCase    )
					_lowercase			:     List[Any]      					=				size if size is not None else {"shortest_edge": 2_2_4}
					_lowercase			:     Optional[int]      					=				get_size_dict(__lowerCamelCase      ,       default_to_square=__lowerCamelCase    )
					_lowercase			:     Tuple      					=				crop_size if crop_size is not None else {"height": 2_2_4, "width": 2_2_4}
					_lowercase			:     Optional[int]      					=				get_size_dict(__lowerCamelCase    )

					_lowercase			:     str      					=				do_resize
					_lowercase			:     int      					=				size
					_lowercase			:     str      					=				resample
					_lowercase			:     Optional[Any]      					=				do_center_crop
					_lowercase			:     int      					=				crop_size
					_lowercase			:     Optional[Any]      					=				do_rescale
					_lowercase			:     Any      					=				rescale_factor
					_lowercase			:     Any      					=				do_normalize
					_lowercase			:     Any      					=				image_mean if image_mean is not None else OPENAI_CLIP_MEAN
					_lowercase			:     str      					=				image_std if image_std is not None else OPENAI_CLIP_STD
					_lowercase			:     Optional[int]      					=				do_convert_rgb







				def 				__UpperCAmelCase       (			self     :							List[str]      ,       lowerCamelCase_     :							np.ndarray      ,       lowerCamelCase_     :							Dict[str, int]      ,       lowerCamelCase_     :							PILImageResampling = PILImageResampling.BICUBIC      ,       lowerCamelCase_     :							Optional[Union[str, ChannelDimension]] = None      ,       **lowerCamelCase_     :							Optional[int]      ,       ):

					"""simple docstring"""






					_lowercase			:     Any      					=				get_size_dict(__lowerCamelCase      ,       default_to_square=__lowerCamelCase    )
					_lowercase			:     Optional[Any]      					=				get_resize_output_image_size(
					    __lowerCamelCase      ,       size=(size['height'], size['width'])      ,       default_to_square=__lowerCamelCase    )
					return resize(__lowerCamelCase      ,       size=__lowerCamelCase      ,       resample=__lowerCamelCase      ,       data_format=__lowerCamelCase      ,       **__lowerCamelCase    )







				def 				__UpperCAmelCase       (			self     :							Any      ,       lowerCamelCase_     :							np.ndarray      ,       lowerCamelCase_     :							Dict[str, int]      ,       lowerCamelCase_     :							Optional[Union[str, ChannelDimension]] = None      ,       **lowerCamelCase_     :							Any      ,       ):

					"""simple docstring"""






					_lowercase			:     Dict      					=				get_size_dict(__lowerCamelCase    )
					return center_crop(__lowerCamelCase      ,       size=(size['height'], size['width'])      ,       data_format=__lowerCamelCase      ,       **__lowerCamelCase    )







				def 				__UpperCAmelCase       (			self     :							Optional[Any]      ,       lowerCamelCase_     :							np.ndarray      ,       lowerCamelCase_     :							Union[int, float]      ,       lowerCamelCase_     :							Optional[Union[str, ChannelDimension]] = None      ,       **lowerCamelCase_     :							str      ,       ):

					"""simple docstring"""






					return rescale(__lowerCamelCase      ,       scale=__lowerCamelCase      ,       data_format=__lowerCamelCase      ,       **__lowerCamelCase    )







				def 				__UpperCAmelCase       (			self     :							Tuple      ,       lowerCamelCase_     :							np.ndarray      ,       lowerCamelCase_     :							Union[float, List[float]]      ,       lowerCamelCase_     :							Union[float, List[float]]      ,       lowerCamelCase_     :							Optional[Union[str, ChannelDimension]] = None      ,       **lowerCamelCase_     :							Optional[Any]      ,       ):

					"""simple docstring"""






					return normalize(__lowerCamelCase      ,       mean=__lowerCamelCase      ,       std=__lowerCamelCase      ,       data_format=__lowerCamelCase      ,       **__lowerCamelCase    )







				def 				__UpperCAmelCase       (			self     :							str      ,       lowerCamelCase_     :							ImageInput      ,       lowerCamelCase_     :							bool = None      ,       lowerCamelCase_     :							Dict[str, int] = None      ,       lowerCamelCase_     :							PILImageResampling = None      ,       lowerCamelCase_     :							bool = None      ,       lowerCamelCase_     :							int = None      ,       lowerCamelCase_     :							bool = None      ,       lowerCamelCase_     :							float = None      ,       lowerCamelCase_     :							bool = None      ,       lowerCamelCase_     :							Optional[Union[float, List[float]]] = None      ,       lowerCamelCase_     :							Optional[Union[float, List[float]]] = None      ,       lowerCamelCase_     :							bool = None      ,       lowerCamelCase_     :							Optional[Union[str, TensorType]] = None      ,       lowerCamelCase_     :							Optional[ChannelDimension] = ChannelDimension.FIRST      ,       **lowerCamelCase_     :							Tuple      ,       ):

					"""simple docstring"""






					_lowercase			:     Any      					=				do_resize if do_resize is not None else self.do_resize
					_lowercase			:     Tuple      					=				size if size is not None else self.size
					_lowercase			:     Dict      					=				get_size_dict(__lowerCamelCase      ,       default_to_square=__lowerCamelCase    )
					_lowercase			:     List[str]      					=				resample if resample is not None else self.resample
					_lowercase			:     List[str]      					=				do_center_crop if do_center_crop is not None else self.do_center_crop
					_lowercase			:     Optional[Any]      					=				crop_size if crop_size is not None else self.crop_size
					_lowercase			:     Optional[Any]      					=				get_size_dict(__lowerCamelCase    )
					_lowercase			:     Any      					=				do_rescale if do_rescale is not None else self.do_rescale
					_lowercase			:     List[str]      					=				rescale_factor if rescale_factor is not None else self.rescale_factor
					_lowercase			:     Tuple      					=				do_normalize if do_normalize is not None else self.do_normalize
					_lowercase			:     List[Any]      					=				image_mean if image_mean is not None else self.image_mean
					_lowercase			:     str      					=				image_std if image_std is not None else self.image_std
					_lowercase			:     List[str]      					=				do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

					_lowercase			:     Any      					=				make_list_of_images(__lowerCamelCase    )

					if not valid_images(__lowerCamelCase    ):
						raise ValueError(
						    'Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, '
						    'torch.Tensor, tf.Tensor or jax.ndarray.'    )

					if do_resize and size is None:
						raise ValueError('Size must be specified if do_resize is True.'    )

					if do_center_crop and crop_size is None:
						raise ValueError('Crop size must be specified if do_center_crop is True.'    )

					if do_rescale and rescale_factor is None:
						raise ValueError('Rescale factor must be specified if do_rescale is True.'    )

					if do_normalize and (image_mean is None or image_std is None):
						raise ValueError('Image mean and std must be specified if do_normalize is True.'    )

					# PIL RGBA images are converted to RGB
					if do_convert_rgb:
						_lowercase			:     Dict      					=				[convert_to_rgb(__lowerCamelCase    ) for image in images]

					# All transformations expect numpy arrays.
					_lowercase			:     Optional[int]      					=				[to_numpy_array(__lowerCamelCase    ) for image in images]

					if do_resize:
						_lowercase			:     str      					=				[self.resize(image=__lowerCamelCase      ,       size=__lowerCamelCase      ,       resample=__lowerCamelCase    ) for image in images]

					if do_center_crop:
						_lowercase			:     Optional[Any]      					=				[self.center_crop(image=__lowerCamelCase      ,       size=__lowerCamelCase    ) for image in images]

					if do_rescale:
						_lowercase			:     int      					=				[self.rescale(image=__lowerCamelCase      ,       scale=__lowerCamelCase    ) for image in images]

					if do_normalize:
						_lowercase			:     int      					=				[self.normalize(image=__lowerCamelCase      ,       mean=__lowerCamelCase      ,       std=__lowerCamelCase    ) for image in images]

					_lowercase			:     Optional[Any]      					=				[to_channel_dimension_format(__lowerCamelCase      ,       __lowerCamelCase    ) for image in images]

					_lowercase			:     Dict      					=				{"pixel_values": images}
					return BatchFeature(data=__lowerCamelCase      ,       tensor_type=__lowerCamelCase    )







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      _lowercase					:


       """simple docstring"""




       def __init__(  self				:     Dict   , __lowerCamelCase				:     Optional[Any]   , __lowerCamelCase				:     Union[str, Any]=13   , __lowerCamelCase				:     Optional[Any]=7   , __lowerCamelCase				:     List[str]=True   , __lowerCamelCase				:     str=True   , __lowerCamelCase				:     List[str]=True   , __lowerCamelCase				:     List[str]=True   , __lowerCamelCase				:     Optional[int]=99   , __lowerCamelCase				:     Dict=32   , __lowerCamelCase				:     List[str]=5   , __lowerCamelCase				:     str=4   , __lowerCamelCase				:     str=37   , __lowerCamelCase				:     Any="gelu"   , __lowerCamelCase				:     Dict=0.1   , __lowerCamelCase				:     Optional[Any]=0.1   , __lowerCamelCase				:     List[str]=512   , __lowerCamelCase				:     str=16   , __lowerCamelCase				:     List[Any]=2   , __lowerCamelCase				:     int=0.0_2   , __lowerCamelCase				:     Any=3   , __lowerCamelCase				:     Optional[int]=None   , __lowerCamelCase				:     str=20   , __lowerCamelCase				:     Union[str, Any]=30   , __lowerCamelCase				:     str=2   , __lowerCamelCase				:     Dict=2   , __lowerCamelCase				:     str=10   , ):


             '''simple docstring'''



             lowerCamelCase__						:							Optional[int]       =    parent
             lowerCamelCase__						:							Optional[Any]       =    batch_size
             lowerCamelCase__						:							Union[str, Any]       =    seq_length
             lowerCamelCase__						:							Union[str, Any]       =    is_training
             lowerCamelCase__						:							Tuple       =    use_input_mask
             lowerCamelCase__						:							Tuple       =    use_token_type_ids
             lowerCamelCase__						:							Union[str, Any]       =    use_labels
             lowerCamelCase__						:							str       =    vocab_size
             lowerCamelCase__						:							int       =    hidden_size
             lowerCamelCase__						:							List[Any]       =    num_hidden_layers
             lowerCamelCase__						:							List[Any]       =    num_attention_heads
             lowerCamelCase__						:							Optional[Any]       =    intermediate_size
             lowerCamelCase__						:							int       =    hidden_act
             lowerCamelCase__						:							Optional[Any]       =    hidden_dropout_prob
             lowerCamelCase__						:							Optional[Any]       =    attention_probs_dropout_prob
             lowerCamelCase__						:							Optional[int]       =    max_position_embeddings
             lowerCamelCase__						:							Optional[Any]       =    type_vocab_size
             lowerCamelCase__						:							Tuple       =    type_sequence_label_size
             lowerCamelCase__						:							List[Any]       =    initializer_range
             lowerCamelCase__						:							str       =    num_labels
             lowerCamelCase__						:							Dict       =    scope
             lowerCamelCase__						:							List[Any]       =    max_xpath_tag_unit_embeddings
             lowerCamelCase__						:							str       =    max_xpath_subs_unit_embeddings
             lowerCamelCase__						:							Optional[Any]       =    tag_pad_id
             lowerCamelCase__						:							Optional[Any]       =    subs_pad_id
             lowerCamelCase__						:							Optional[int]       =    max_depth





       def 		lowerCAmelCase	(  self				:     int			):


             '''simple docstring'''



             lowerCamelCase__						:							Dict       =    ids_tensor([self.batch_size, self.seq_length]   , self.vocab_size			)

             lowerCamelCase__						:							List[Any]       =    ids_tensor(
                 [self.batch_size, self.seq_length, self.max_depth]   , self.max_xpath_tag_unit_embeddings			)

             lowerCamelCase__						:							int       =    ids_tensor(
                 [self.batch_size, self.seq_length, self.max_depth]   , self.max_xpath_subs_unit_embeddings			)

             lowerCamelCase__						:							List[Any]       =    None
             if self.use_input_mask:
                   lowerCamelCase__						:							Tuple       =    ids_tensor([self.batch_size, self.seq_length]   , vocab_size=2			)

             lowerCamelCase__						:							int       =    None
             if self.use_token_type_ids:
                   lowerCamelCase__						:							Union[str, Any]       =    ids_tensor([self.batch_size, self.seq_length]   , self.type_vocab_size			)

             lowerCamelCase__						:							Any       =    None
             lowerCamelCase__						:							str       =    None
             if self.use_labels:
                   lowerCamelCase__						:							Dict       =    ids_tensor([self.batch_size]   , self.type_sequence_label_size			)
                   lowerCamelCase__						:							Optional[Any]       =    ids_tensor([self.batch_size, self.seq_length]   , self.num_labels			)

             lowerCamelCase__						:							int       =    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				:     int			):


             '''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				:     Optional[Any]   , __lowerCamelCase				:     Union[str, Any]   , __lowerCamelCase				:     Optional[int]   , __lowerCamelCase				:     str   , __lowerCamelCase				:     Tuple   , __lowerCamelCase				:     List[Any]   , __lowerCamelCase				:     List[Any]   , __lowerCamelCase				:     Any   , __lowerCamelCase				:     str   , ):


             '''simple docstring'''



             lowerCamelCase__						:							List[Any]       =    MarkupLMModel(config=__lowerCamelCase			)
             model.to(__lowerCamelCase			)
             model.eval()
             print("Configs:"   , model.config.tag_pad_id   , model.config.subs_pad_id			)
             lowerCamelCase__						:							Optional[int]       =    model(__lowerCamelCase   , attention_mask=__lowerCamelCase   , token_type_ids=__lowerCamelCase			)
             lowerCamelCase__						:							List[str]       =    model(__lowerCamelCase   , token_type_ids=__lowerCamelCase			)
             lowerCamelCase__						:							str       =    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				:     Dict   , __lowerCamelCase				:     Union[str, Any]   , __lowerCamelCase				:     Tuple   , __lowerCamelCase				:     int   , __lowerCamelCase				:     Dict   , __lowerCamelCase				:     Optional[Any]   , __lowerCamelCase				:     Tuple   , __lowerCamelCase				:     Optional[Any]   , __lowerCamelCase				:     List[Any]   , ):


             '''simple docstring'''



             lowerCamelCase__						:							Optional[Any]       =    self.num_labels
             lowerCamelCase__						:							str       =    MarkupLMForSequenceClassification(__lowerCamelCase			)
             model.to(__lowerCamelCase			)
             model.eval()
             lowerCamelCase__						:							Optional[int]       =    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				:     Any   , __lowerCamelCase				:     Optional[int]   , __lowerCamelCase				:     Any   , __lowerCamelCase				:     Any   , __lowerCamelCase				:     Any   , __lowerCamelCase				:     List[str]   , __lowerCamelCase				:     List[Any]   , __lowerCamelCase				:     int   , __lowerCamelCase				:     str   , ):


             '''simple docstring'''



             lowerCamelCase__						:							List[str]       =    self.num_labels
             lowerCamelCase__						:							Tuple       =    MarkupLMForTokenClassification(config=__lowerCamelCase			)
             model.to(__lowerCamelCase			)
             model.eval()
             lowerCamelCase__						:							List[Any]       =    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				:     Tuple   , __lowerCamelCase				:     int   , __lowerCamelCase				:     List[Any]   , __lowerCamelCase				:     Optional[int]   , __lowerCamelCase				:     List[str]   , __lowerCamelCase				:     List[Any]   , __lowerCamelCase				:     Dict   , __lowerCamelCase				:     Optional[int]   , __lowerCamelCase				:     Any   , ):


             '''simple docstring'''



             lowerCamelCase__						:							Union[str, Any]       =    MarkupLMForQuestionAnswering(config=__lowerCamelCase			)
             model.to(__lowerCamelCase			)
             model.eval()
             lowerCamelCase__						:							Union[str, Any]       =    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[str]			):


             '''simple docstring'''



             lowerCamelCase__						:							Union[str, Any]       =    self.prepare_config_and_inputs()
             (
                 (
                 lowerCamelCase__
             )       ,  (
                 lowerCamelCase__
             )       ,  (
                 lowerCamelCase__
             )       ,  (
                 lowerCamelCase__
             )       ,  (
                 lowerCamelCase__
             )       ,  (
                 lowerCamelCase__
             )       ,  (
                 lowerCamelCase__
             )       ,  (
                 lowerCamelCase__
             )       ,  
             )						:							Optional[int]       =    config_and_inputs
             lowerCamelCase__						:							List[str]       =    {
                 "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      _lowercase					(				lowercase__				,    lowercase__				,    unittest.TestCase):


       """simple docstring"""




       A__   		=     (
           (
               MarkupLMModel,
               MarkupLMForSequenceClassification,
               MarkupLMForTokenClassification,
               MarkupLMForQuestionAnswering,
           )
           if is_torch_available()
           else None
       )
       A__   		=     (
           {
               "feature-extraction": MarkupLMModel,
               "question-answering": MarkupLMForQuestionAnswering,
               "text-classification": MarkupLMForSequenceClassification,
               "token-classification": MarkupLMForTokenClassification,
               "zero-shot": MarkupLMForSequenceClassification,
           }
           if is_torch_available()
           else {}
       )





       def 		lowerCAmelCase	(  self				:     int   , __lowerCamelCase				:     Optional[Any]   , __lowerCamelCase				:     int   , __lowerCamelCase				:     Any   , __lowerCamelCase				:     Any   , __lowerCamelCase				:     List[str]			):


             '''simple docstring'''



             return True





       def 		lowerCAmelCase	(  self				:     List[str]			):


             '''simple docstring'''



             lowerCamelCase__						:							Any       =    MarkupLMModelTester(self			)
             lowerCamelCase__						:							Any       =    ConfigTester(self   , config_class=__lowerCamelCase   , hidden_size=37			)





       def 		lowerCAmelCase	(  self				:     Dict			):


             '''simple docstring'''



             self.config_tester.run_common_tests()





       def 		lowerCAmelCase	(  self				:     List[Any]			):


             '''simple docstring'''



             lowerCamelCase__						:							Union[str, Any]       =    self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_model(*__lowerCamelCase			)





       def 		lowerCAmelCase	(  self				:     int			):


             '''simple docstring'''



             lowerCamelCase__						:							Dict       =    self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_sequence_classification(*__lowerCamelCase			)





       def 		lowerCAmelCase	(  self				:     Tuple			):


             '''simple docstring'''



             lowerCamelCase__						:							Optional[Any]       =    self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_token_classification(*__lowerCamelCase			)





       def 		lowerCAmelCase	(  self				:     List[Any]			):


             '''simple docstring'''



             lowerCamelCase__						:							List[Any]       =    self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_question_answering(*__lowerCamelCase			)



def  lowercase_						(						):

      """simple docstring"""




      lowerCamelCase__						:							int       =    "\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      _lowercase					(				unittest.TestCase):


       """simple docstring"""




       @cached_property
       def 		lowerCAmelCase	(  self				:     Tuple			):


             '''simple docstring'''



             lowerCamelCase__						:							Union[str, Any]       =    MarkupLMFeatureExtractor()
             lowerCamelCase__						:							Union[str, Any]       =    MarkupLMTokenizer.from_pretrained("microsoft/markuplm-base"			)

             return MarkupLMProcessor(__lowerCamelCase   , __lowerCamelCase			)





       @slow
       def 		lowerCAmelCase	(  self				:     Optional[Any]			):


             '''simple docstring'''



             lowerCamelCase__						:							Union[str, Any]       =    MarkupLMModel.from_pretrained("microsoft/markuplm-base"			).to(__lowerCamelCase			)

             lowerCamelCase__						:							Dict       =    self.default_processor

             lowerCamelCase__						:							Dict       =    processor(prepare_html_string()   , return_tensors="pt"			)
             lowerCamelCase__						:							Optional[Any]       =    inputs.to(__lowerCamelCase			)

             # forward pass
             with torch.no_grad():
                   lowerCamelCase__						:							Union[str, Any]       =    model(**__lowerCamelCase			)

             # verify the last hidden states
             lowerCamelCase__						:							Dict       =    torch.Size([1, 14, 768]			)
             self.assertEqual(outputs.last_hidden_state.shape   , __lowerCamelCase			)

             lowerCamelCase__						:							Dict       =    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(__lowerCamelCase			)

             self.assertTrue(torch.allclose(outputs.last_hidden_state[0, :3, :3]   , __lowerCamelCase   , atol=1E-4			)			)


