


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





     def __init__(     self       :					int     ,						SCREAMING_SNAKE_CASE_       :					List[str]     ,						SCREAMING_SNAKE_CASE_       :					Dict=13     ,						SCREAMING_SNAKE_CASE_       :					int=7     ,						SCREAMING_SNAKE_CASE_       :					Optional[Any]=True     ,						SCREAMING_SNAKE_CASE_       :					int=True     ,						SCREAMING_SNAKE_CASE_       :					Dict=True     ,						SCREAMING_SNAKE_CASE_       :					Union[str, Any]=True     ,						SCREAMING_SNAKE_CASE_       :					Optional[int]=99     ,						SCREAMING_SNAKE_CASE_       :					Optional[Any]=32     ,						SCREAMING_SNAKE_CASE_       :					List[Any]=5     ,						SCREAMING_SNAKE_CASE_       :					List[str]=4     ,						SCREAMING_SNAKE_CASE_       :					Dict=37     ,						SCREAMING_SNAKE_CASE_       :					Union[str, Any]="gelu"     ,						SCREAMING_SNAKE_CASE_       :					List[str]=0.1     ,						SCREAMING_SNAKE_CASE_       :					Any=0.1     ,						SCREAMING_SNAKE_CASE_       :					List[str]=512     ,						SCREAMING_SNAKE_CASE_       :					List[Any]=16     ,						SCREAMING_SNAKE_CASE_       :					List[str]=2     ,						SCREAMING_SNAKE_CASE_       :					str=0.02     ,						SCREAMING_SNAKE_CASE_       :					List[str]=3     ,						SCREAMING_SNAKE_CASE_       :					Optional[Any]=None     ,						SCREAMING_SNAKE_CASE_       :					Any=20     ,						SCREAMING_SNAKE_CASE_       :					Optional[Any]=30     ,						SCREAMING_SNAKE_CASE_       :					int=2     ,						SCREAMING_SNAKE_CASE_       :					Union[str, Any]=2     ,						SCREAMING_SNAKE_CASE_       :					Optional[int]=10     ,						):
        __lowerCamelCase:					str	 =						parent
        __lowerCamelCase:					Optional[int]	 =						batch_size
        __lowerCamelCase:					int	 =						seq_length
        __lowerCamelCase:					int	 =						is_training
        __lowerCamelCase:					List[Any]	 =						use_input_mask
        __lowerCamelCase:					Tuple	 =						use_token_type_ids
        __lowerCamelCase:					Optional[Any]	 =						use_labels
        __lowerCamelCase:					Dict	 =						vocab_size
        __lowerCamelCase:					List[Any]	 =						hidden_size
        __lowerCamelCase:					Any	 =						num_hidden_layers
        __lowerCamelCase:					Tuple	 =						num_attention_heads
        __lowerCamelCase:					Any	 =						intermediate_size
        __lowerCamelCase:					Optional[int]	 =						hidden_act
        __lowerCamelCase:					Optional[int]	 =						hidden_dropout_prob
        __lowerCamelCase:					int	 =						attention_probs_dropout_prob
        __lowerCamelCase:					int	 =						max_position_embeddings
        __lowerCamelCase:					int	 =						type_vocab_size
        __lowerCamelCase:					Dict	 =						type_sequence_label_size
        __lowerCamelCase:					int	 =						initializer_range
        __lowerCamelCase:					Dict	 =						num_labels
        __lowerCamelCase:					Tuple	 =						scope
        __lowerCamelCase:					str	 =						max_xpath_tag_unit_embeddings
        __lowerCamelCase:					Any	 =						max_xpath_subs_unit_embeddings
        __lowerCamelCase:					Dict	 =						tag_pad_id
        __lowerCamelCase:					Any	 =						subs_pad_id
        __lowerCamelCase:					Union[str, Any]	 =						max_depth





     def 			SCREAMING_SNAKE_CASE__							(     self       :					Any				):
        __lowerCamelCase:					Union[str, Any]	 =						ids_tensor([self.batch_size, self.seq_length]     ,						self.vocab_size				)

        __lowerCamelCase:					List[str]	 =						ids_tensor(
            [self.batch_size, self.seq_length, self.max_depth]     ,						self.max_xpath_tag_unit_embeddings				)

        __lowerCamelCase:					List[str]	 =						ids_tensor(
            [self.batch_size, self.seq_length, self.max_depth]     ,						self.max_xpath_subs_unit_embeddings				)

        __lowerCamelCase:					str	 =						None
        if self.use_input_mask:
           __lowerCamelCase:					Tuple	 =						ids_tensor([self.batch_size, self.seq_length]     ,						vocab_size=2				)

        __lowerCamelCase:					Tuple	 =						None
        if self.use_token_type_ids:
           __lowerCamelCase:					Dict	 =						ids_tensor([self.batch_size, self.seq_length]     ,						self.type_vocab_size				)

        __lowerCamelCase:					List[str]	 =						None
        __lowerCamelCase:					List[str]	 =						None
        if self.use_labels:
           __lowerCamelCase:					Optional[int]	 =						ids_tensor([self.batch_size]     ,						self.type_sequence_label_size				)
           __lowerCamelCase:					List[str]	 =						ids_tensor([self.batch_size, self.seq_length]     ,						self.num_labels				)

        __lowerCamelCase:					Any	 =						self.get_config()

        return (
            config,
            input_ids,
            xpath_tags_seq,
            xpath_subs_seq,
            token_type_ids,
            input_mask,
            sequence_labels,
            token_labels,
        )





     def 			SCREAMING_SNAKE_CASE__							(     self       :					List[str]				):
        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 			SCREAMING_SNAKE_CASE__							(     self       :					Optional[Any]     ,						SCREAMING_SNAKE_CASE_       :					int     ,						SCREAMING_SNAKE_CASE_       :					Optional[int]     ,						SCREAMING_SNAKE_CASE_       :					Optional[Any]     ,						SCREAMING_SNAKE_CASE_       :					Optional[int]     ,						SCREAMING_SNAKE_CASE_       :					Dict     ,						SCREAMING_SNAKE_CASE_       :					Tuple     ,						SCREAMING_SNAKE_CASE_       :					Union[str, Any]     ,						SCREAMING_SNAKE_CASE_       :					List[Any]     ,						):
        __lowerCamelCase:					Optional[int]	 =						MarkupLMModel(config=SCREAMING_SNAKE_CASE_				)
        model.to(SCREAMING_SNAKE_CASE_				)
        model.eval()
        print("""Configs:"""     ,						model.config.tag_pad_id     ,						model.config.subs_pad_id				)
        __lowerCamelCase:					Optional[Any]	 =						model(SCREAMING_SNAKE_CASE_     ,						attention_mask=SCREAMING_SNAKE_CASE_     ,						token_type_ids=SCREAMING_SNAKE_CASE_				)
        __lowerCamelCase:					int	 =						model(SCREAMING_SNAKE_CASE_     ,						token_type_ids=SCREAMING_SNAKE_CASE_				)
        __lowerCamelCase:					Any	 =						model(SCREAMING_SNAKE_CASE_				)
        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 			SCREAMING_SNAKE_CASE__							(     self       :					int     ,						SCREAMING_SNAKE_CASE_       :					Optional[Any]     ,						SCREAMING_SNAKE_CASE_       :					Tuple     ,						SCREAMING_SNAKE_CASE_       :					List[Any]     ,						SCREAMING_SNAKE_CASE_       :					int     ,						SCREAMING_SNAKE_CASE_       :					Any     ,						SCREAMING_SNAKE_CASE_       :					Union[str, Any]     ,						SCREAMING_SNAKE_CASE_       :					Optional[Any]     ,						SCREAMING_SNAKE_CASE_       :					Tuple     ,						):
        __lowerCamelCase:					Optional[Any]	 =						self.num_labels
        __lowerCamelCase:					List[str]	 =						MarkupLMForSequenceClassification(SCREAMING_SNAKE_CASE_				)
        model.to(SCREAMING_SNAKE_CASE_				)
        model.eval()
        __lowerCamelCase:					Union[str, Any]	 =						model(
            SCREAMING_SNAKE_CASE_     ,						xpath_tags_seq=SCREAMING_SNAKE_CASE_     ,						xpath_subs_seq=SCREAMING_SNAKE_CASE_     ,						attention_mask=SCREAMING_SNAKE_CASE_     ,						token_type_ids=SCREAMING_SNAKE_CASE_     ,						labels=SCREAMING_SNAKE_CASE_     ,						)
        self.parent.assertEqual(result.logits.shape     ,						(self.batch_size, self.num_labels)				)





     def 			SCREAMING_SNAKE_CASE__							(     self       :					Union[str, Any]     ,						SCREAMING_SNAKE_CASE_       :					List[Any]     ,						SCREAMING_SNAKE_CASE_       :					List[str]     ,						SCREAMING_SNAKE_CASE_       :					int     ,						SCREAMING_SNAKE_CASE_       :					int     ,						SCREAMING_SNAKE_CASE_       :					Optional[Any]     ,						SCREAMING_SNAKE_CASE_       :					Any     ,						SCREAMING_SNAKE_CASE_       :					str     ,						SCREAMING_SNAKE_CASE_       :					List[Any]     ,						):
        __lowerCamelCase:					List[Any]	 =						self.num_labels
        __lowerCamelCase:					Tuple	 =						MarkupLMForTokenClassification(config=SCREAMING_SNAKE_CASE_				)
        model.to(SCREAMING_SNAKE_CASE_				)
        model.eval()
        __lowerCamelCase:					Tuple	 =						model(
            SCREAMING_SNAKE_CASE_     ,						xpath_tags_seq=SCREAMING_SNAKE_CASE_     ,						xpath_subs_seq=SCREAMING_SNAKE_CASE_     ,						attention_mask=SCREAMING_SNAKE_CASE_     ,						token_type_ids=SCREAMING_SNAKE_CASE_     ,						labels=SCREAMING_SNAKE_CASE_     ,						)
        self.parent.assertEqual(result.logits.shape     ,						(self.batch_size, self.seq_length, self.num_labels)				)





     def 			SCREAMING_SNAKE_CASE__							(     self       :					Tuple     ,						SCREAMING_SNAKE_CASE_       :					int     ,						SCREAMING_SNAKE_CASE_       :					Union[str, Any]     ,						SCREAMING_SNAKE_CASE_       :					Optional[int]     ,						SCREAMING_SNAKE_CASE_       :					Optional[int]     ,						SCREAMING_SNAKE_CASE_       :					Dict     ,						SCREAMING_SNAKE_CASE_       :					Optional[Any]     ,						SCREAMING_SNAKE_CASE_       :					Union[str, Any]     ,						SCREAMING_SNAKE_CASE_       :					Tuple     ,						):
        __lowerCamelCase:					List[Any]	 =						MarkupLMForQuestionAnswering(config=SCREAMING_SNAKE_CASE_				)
        model.to(SCREAMING_SNAKE_CASE_				)
        model.eval()
        __lowerCamelCase:					Dict	 =						model(
            SCREAMING_SNAKE_CASE_     ,						xpath_tags_seq=SCREAMING_SNAKE_CASE_     ,						xpath_subs_seq=SCREAMING_SNAKE_CASE_     ,						attention_mask=SCREAMING_SNAKE_CASE_     ,						token_type_ids=SCREAMING_SNAKE_CASE_     ,						start_positions=SCREAMING_SNAKE_CASE_     ,						end_positions=SCREAMING_SNAKE_CASE_     ,						)
        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 			SCREAMING_SNAKE_CASE__							(     self       :					List[Any]				):
        __lowerCamelCase:					Tuple	 =						self.prepare_config_and_inputs()
        (
            (
            __lowerCamelCase
        ) ,  (
            __lowerCamelCase
        ) ,  (
            __lowerCamelCase
        ) ,  (
            __lowerCamelCase
        ) ,  (
            __lowerCamelCase
        ) ,  (
            __lowerCamelCase
        ) ,  (
            __lowerCamelCase
        ) ,  (
            __lowerCamelCase
        ) ,  
        ):					Union[str, Any]	 =						config_and_inputs
        __lowerCamelCase:					Tuple	 =						{
            """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 							a       (      _UpperCAmelCase  ,_UpperCAmelCase  ,unittest.TestCase ):
     UpperCAmelCase__			:	Optional[int]       =						(
         (
             MarkupLMModel,
             MarkupLMForSequenceClassification,
             MarkupLMForTokenClassification,
             MarkupLMForQuestionAnswering,
         )
         if is_torch_available()
         else None
     )
     UpperCAmelCase__			:	Union[str, Any]       =						(
         {
             "feature-extraction": MarkupLMModel,
             "question-answering": MarkupLMForQuestionAnswering,
             "text-classification": MarkupLMForSequenceClassification,
             "token-classification": MarkupLMForTokenClassification,
             "zero-shot": MarkupLMForSequenceClassification,
         }
         if is_torch_available()
         else {}
     )





     def 			SCREAMING_SNAKE_CASE__							(     self       :					str     ,						SCREAMING_SNAKE_CASE_       :					Tuple     ,						SCREAMING_SNAKE_CASE_       :					Any     ,						SCREAMING_SNAKE_CASE_       :					Tuple     ,						SCREAMING_SNAKE_CASE_       :					Tuple     ,						SCREAMING_SNAKE_CASE_       :					str				):
        # ValueError: Nodes must be of type `List[str]` (single pretokenized example), or `List[List[str]]`
        # (batch of pretokenized examples).
        return True





     def 			SCREAMING_SNAKE_CASE__							(     self       :					str				):
        __lowerCamelCase:					Union[str, Any]	 =						MarkupLMModelTester(self				)
        __lowerCamelCase:					Union[str, Any]	 =						ConfigTester(self     ,						config_class=SCREAMING_SNAKE_CASE_     ,						hidden_size=37				)





     def 			SCREAMING_SNAKE_CASE__							(     self       :					int				):
        self.config_tester.run_common_tests()





     def 			SCREAMING_SNAKE_CASE__							(     self       :					Dict				):
        __lowerCamelCase:					Tuple	 =						self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_				)





     def 			SCREAMING_SNAKE_CASE__							(     self       :					str				):
        __lowerCamelCase:					List[str]	 =						self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_sequence_classification(*SCREAMING_SNAKE_CASE_				)





     def 			SCREAMING_SNAKE_CASE__							(     self       :					List[Any]				):
        __lowerCamelCase:					List[str]	 =						self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_token_classification(*SCREAMING_SNAKE_CASE_				)







     def 			SCREAMING_SNAKE_CASE__							(     self       :					str				):
        __lowerCamelCase:					List[str]	 =						self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_question_answering(*SCREAMING_SNAKE_CASE_				)



def      __lowerCAmelCase    (				)							->				Union[str, Any]:
   __lowerCamelCase:					List[str]	 =						"""
    <!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 							a       (      unittest.TestCase ):





     @cached_property
     def 			SCREAMING_SNAKE_CASE__							(     self       :					Any				):
        # TODO use from_pretrained here
        __lowerCamelCase:					Optional[int]	 =						MarkupLMFeatureExtractor()
        __lowerCamelCase:					Any	 =						MarkupLMTokenizer.from_pretrained("""microsoft/markuplm-base"""				)

        return MarkupLMProcessor(SCREAMING_SNAKE_CASE_     ,						SCREAMING_SNAKE_CASE_				)







     @slow
     def 			SCREAMING_SNAKE_CASE__							(     self       :					int				):
        __lowerCamelCase:					str	 =						MarkupLMModel.from_pretrained("""microsoft/markuplm-base"""				).to(SCREAMING_SNAKE_CASE_				)

        __lowerCamelCase:					Dict	 =						self.default_processor

        __lowerCamelCase:					Any	 =						processor(prepare_html_string()     ,						return_tensors="""pt"""				)
        __lowerCamelCase:					Tuple	 =						inputs.to(SCREAMING_SNAKE_CASE_				)

        # forward pass
        with torch.no_grad():
           __lowerCamelCase:					Optional[Any]	 =						model(**SCREAMING_SNAKE_CASE_				)

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

        __lowerCamelCase:					Tuple	 =						torch.tensor(
            [[0.0675, -0.0052, 0.5001], [-0.2281, 0.0802, 0.2192], [-0.0583, -0.3311, 0.1185]]				).to(SCREAMING_SNAKE_CASE_				)

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






import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
   import torch

if is_vision_available():
   from PIL import Image

   from transformers import MobileNetVaImageProcessor



class 							a       (      unittest.TestCase ):





     def __init__(     self       :					Optional[int]     ,						SCREAMING_SNAKE_CASE_       :					str     ,						SCREAMING_SNAKE_CASE_       :					List[str]=7     ,						SCREAMING_SNAKE_CASE_       :					Union[str, Any]=3     ,						SCREAMING_SNAKE_CASE_       :					List[Any]=18     ,						SCREAMING_SNAKE_CASE_       :					List[str]=30     ,						SCREAMING_SNAKE_CASE_       :					List[Any]=400     ,						SCREAMING_SNAKE_CASE_       :					Dict=True     ,						SCREAMING_SNAKE_CASE_       :					Any=None     ,						SCREAMING_SNAKE_CASE_       :					List[str]=True     ,						SCREAMING_SNAKE_CASE_       :					Any=None     ,						):
        __lowerCamelCase:					List[Any]	 =						size if size is not None else {"""shortest_edge""": 20}
        __lowerCamelCase:					Tuple	 =						crop_size if crop_size is not None else {"""height""": 18, """width""": 18}
        __lowerCamelCase:					List[Any]	 =						parent
        __lowerCamelCase:					Optional[int]	 =						batch_size
        __lowerCamelCase:					str	 =						num_channels
        __lowerCamelCase:					Dict	 =						image_size
        __lowerCamelCase:					Tuple	 =						min_resolution
        __lowerCamelCase:					Union[str, Any]	 =						max_resolution
        __lowerCamelCase:					Tuple	 =						do_resize
        __lowerCamelCase:					List[str]	 =						size
        __lowerCamelCase:					int	 =						do_center_crop
        __lowerCamelCase:					Tuple	 =						crop_size







     def 			SCREAMING_SNAKE_CASE__							(     self       :					List[Any]				):
        return {
            "do_resize": self.do_resize,
            "size": self.size,
            "do_center_crop": self.do_center_crop,
            "crop_size": self.crop_size,
        }



@require_torch
@require_vision
class 							a       (      _UpperCAmelCase  ,unittest.TestCase ):
     UpperCAmelCase__			:	int       =						MobileNetVaImageProcessor if is_vision_available() else None





     def 			SCREAMING_SNAKE_CASE__							(     self       :					List[str]				):
        __lowerCamelCase:					Tuple	 =						MobileNetVaImageProcessingTester(self				)





     @property
     def 			SCREAMING_SNAKE_CASE__							(     self       :					str				):
        return self.image_processor_tester.prepare_image_processor_dict()





     def 			SCREAMING_SNAKE_CASE__							(     self       :					List[str]				):
        __lowerCamelCase:					List[Any]	 =						self.image_processing_class(**self.image_processor_dict				)
        self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_     ,						"""do_resize"""				)				)
        self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_     ,						"""size"""				)				)
        self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_     ,						"""do_center_crop"""				)				)
        self.assertTrue(hasattr(SCREAMING_SNAKE_CASE_     ,						"""center_crop"""				)				)





     def 			SCREAMING_SNAKE_CASE__							(     self       :					Any				):
        __lowerCamelCase:					str	 =						self.image_processing_class.from_dict(self.image_processor_dict				)
        self.assertEqual(image_processor.size     ,						{"""shortest_edge""": 20}				)
        self.assertEqual(image_processor.crop_size     ,						{"""height""": 18, """width""": 18}				)

        __lowerCamelCase:					Optional[int]	 =						self.image_processing_class.from_dict(self.image_processor_dict     ,						size=42     ,						crop_size=84				)
        self.assertEqual(image_processor.size     ,						{"""shortest_edge""": 42}				)
        self.assertEqual(image_processor.crop_size     ,						{"""height""": 84, """width""": 84}				)





     def 			SCREAMING_SNAKE_CASE__							(     self       :					Optional[Any]				):
        pass





     def 			SCREAMING_SNAKE_CASE__							(     self       :					Optional[int]				):
        # Initialize image_processing
        __lowerCamelCase:					List[str]	 =						self.image_processing_class(**self.image_processor_dict				)
        # create random PIL images
        __lowerCamelCase:					str	 =						prepare_image_inputs(self.image_processor_tester     ,						equal_resolution=SCREAMING_SNAKE_CASE_				)
        for image in image_inputs:
           self.assertIsInstance(SCREAMING_SNAKE_CASE_     ,						Image.Image				)

        # Test not batched input
        __lowerCamelCase:					Optional[Any]	 =						image_processing(image_inputs[0]     ,						return_tensors="""pt"""				).pixel_values
        self.assertEqual(
            encoded_images.shape     ,						(
                1,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.crop_size["""height"""],
                self.image_processor_tester.crop_size["""width"""],
            )     ,						)

        # Test batched
        __lowerCamelCase:					Tuple	 =						image_processing(SCREAMING_SNAKE_CASE_     ,						return_tensors="""pt"""				).pixel_values
        self.assertEqual(
            encoded_images.shape     ,						(
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.crop_size["""height"""],
                self.image_processor_tester.crop_size["""width"""],
            )     ,						)





     def 			SCREAMING_SNAKE_CASE__							(     self       :					Optional[int]				):
        # Initialize image_processing
        __lowerCamelCase:					Union[str, Any]	 =						self.image_processing_class(**self.image_processor_dict				)
        # create random numpy tensors
        __lowerCamelCase:					Tuple	 =						prepare_image_inputs(self.image_processor_tester     ,						equal_resolution=SCREAMING_SNAKE_CASE_     ,						numpify=SCREAMING_SNAKE_CASE_				)
        for image in image_inputs:
           self.assertIsInstance(SCREAMING_SNAKE_CASE_     ,						np.ndarray				)

        # Test not batched input
        __lowerCamelCase:					List[Any]	 =						image_processing(image_inputs[0]     ,						return_tensors="""pt"""				).pixel_values
        self.assertEqual(
            encoded_images.shape     ,						(
                1,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.crop_size["""height"""],
                self.image_processor_tester.crop_size["""width"""],
            )     ,						)

        # Test batched
        __lowerCamelCase:					Optional[Any]	 =						image_processing(SCREAMING_SNAKE_CASE_     ,						return_tensors="""pt"""				).pixel_values
        self.assertEqual(
            encoded_images.shape     ,						(
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.crop_size["""height"""],
                self.image_processor_tester.crop_size["""width"""],
            )     ,						)







     def 			SCREAMING_SNAKE_CASE__							(     self       :					Optional[int]				):
        # Initialize image_processing
        __lowerCamelCase:					str	 =						self.image_processing_class(**self.image_processor_dict				)
        # create random PyTorch tensors
        __lowerCamelCase:					List[str]	 =						prepare_image_inputs(self.image_processor_tester     ,						equal_resolution=SCREAMING_SNAKE_CASE_     ,						torchify=SCREAMING_SNAKE_CASE_				)
        for image in image_inputs:
           self.assertIsInstance(SCREAMING_SNAKE_CASE_     ,						torch.Tensor				)

        # Test not batched input
        __lowerCamelCase:					Union[str, Any]	 =						image_processing(image_inputs[0]     ,						return_tensors="""pt"""				).pixel_values
        self.assertEqual(
            encoded_images.shape     ,						(
                1,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.crop_size["""height"""],
                self.image_processor_tester.crop_size["""width"""],
            )     ,						)

        # Test batched
        __lowerCamelCase:					Optional[int]	 =						image_processing(SCREAMING_SNAKE_CASE_     ,						return_tensors="""pt"""				).pixel_values
        self.assertEqual(
            encoded_images.shape     ,						(
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.crop_size["""height"""],
                self.image_processor_tester.crop_size["""width"""],
            )     ,						)


