

import argparse
import os
import pathlib

import fairseq
import torch
from fairseq.modules import TransformerSentenceEncoderLayer
from packaging import version

from transformers import (
    DataaVecTextConfig,
    DataaVecTextForMaskedLM,
    DataaVecTextForSequenceClassification,
    DataaVecTextModel,
)
from transformers.models.bert.modeling_bert import (
    BertIntermediate,
    BertLayer,
    BertOutput,
    BertSelfAttention,
    BertSelfOutput,
)

# IMPORTANT: In order for this script to run, please make sure to download the dictionary: `dict.txt` from wget https://dl.fbaipublicfiles.com/fairseq/models/roberta.large.tar.gz
# File copied from https://github.com/pytorch/fairseq/blob/main/examples/data2vec/models/data2vec_text.py
from transformers.utils import logging


if version.parse(fairseq.__version__) < version.parse('0.9.0'):
       raise Exception('requires fairseq >= 0.9.0')


logging.set_verbosity_info()
A_						:     Optional[Any]			  =				logging.get_logger(__name__)

A_						:     Dict			  =				'Hello world! cécé herlolip'


def  __a    (				SCREAMING_SNAKE_CASE    ,				SCREAMING_SNAKE_CASE    ,				SCREAMING_SNAKE_CASE ) ->       Optional[int]:






    '''simple docstring'''
    __UpperCAmelCase   ,       __UpperCAmelCase			   =     os.path.split(SCREAMING_SNAKE_CASE )
    __UpperCAmelCase			   =     DataaVecTextModel.from_pretrained(
        SCREAMING_SNAKE_CASE    ,				checkpoint_file=SCREAMING_SNAKE_CASE )
    dataavec.eval()  # disable dropout
    __UpperCAmelCase			   =     dataavec.models[0]
    __UpperCAmelCase			   =     dataavec_model.encoder.sentence_encoder
    __UpperCAmelCase			   =     DataaVecTextConfig(
        vocab_size=dataavec_sent_encoder.embed_tokens.num_embeddings    ,				hidden_size=dataavec_model.args.encoder_embed_dim    ,				num_hidden_layers=dataavec_model.args.encoder_layers    ,				num_attention_heads=dataavec_model.args.encoder_attention_heads    ,				intermediate_size=dataavec_model.args.encoder_ffn_embed_dim    ,				max_position_embeddings=5_1_4    ,				type_vocab_size=1    ,				layer_norm_eps=1e-5    ,				)
    if classification_head:
        __UpperCAmelCase			   =     dataavec.model.classification_heads['''mnli'''].out_proj.weight.shape[0]
    print('''Our BERT config:'''    ,				SCREAMING_SNAKE_CASE )

    __UpperCAmelCase			   =     DataaVecTextForSequenceClassification(SCREAMING_SNAKE_CASE ) if classification_head else DataaVecTextForMaskedLM(SCREAMING_SNAKE_CASE )
    model.eval()

    # Now let's copy all the weights.
    # Embeddings
    __UpperCAmelCase			   =     dataavec_sent_encoder.embed_tokens.weight
    __UpperCAmelCase			   =     dataavec_sent_encoder.embed_positions.weight
    __UpperCAmelCase			   =     torch.zeros_like(
        model.dataavec_text.embeddings.token_type_embeddings.weight )  # just zero them out b/c data2vec doesn't use them.
    __UpperCAmelCase			   =     dataavec_sent_encoder.layernorm_embedding.weight
    __UpperCAmelCase			   =     dataavec_sent_encoder.layernorm_embedding.bias

    for i in range(config.num_hidden_layers ):
        # Encoder: start of layer
        __UpperCAmelCase			   =     model.dataavec_text.encoder.layer[i]
        __UpperCAmelCase			   =     dataavec_sent_encoder.layers[i]

        # self attention
        __UpperCAmelCase			   =     layer.attention.self
        assert dataavec_layer.self_attn.k_proj.weight.data.shape == torch.Size(
            (config.hidden_size, config.hidden_size) ), (
            "Shape for data2vec_layer.self_attn.k_proj.weight.data should be"
            f''' {torch.Size((config.hidden_size, config.hidden_size) )}'''
        )
        assert dataavec_layer.self_attn.q_proj.weight.data.shape == torch.Size(
            (config.hidden_size, config.hidden_size) ), (
            "Shape for data2vec_layer.self_attn.q_proj.weight.data should be"
            f''' {torch.Size((config.hidden_size, config.hidden_size) )}'''
        )
        assert dataavec_layer.self_attn.v_proj.weight.data.shape == torch.Size(
            (config.hidden_size, config.hidden_size) ), (
            "Shape for data2vec_layer.self_attn.v_proj.weight.data should be"
            f''' {torch.Size((config.hidden_size, config.hidden_size) )}'''
        )

        __UpperCAmelCase			   =     dataavec_layer.self_attn.q_proj.weight
        __UpperCAmelCase			   =     dataavec_layer.self_attn.q_proj.bias
        __UpperCAmelCase			   =     dataavec_layer.self_attn.k_proj.weight
        __UpperCAmelCase			   =     dataavec_layer.self_attn.k_proj.bias
        __UpperCAmelCase			   =     dataavec_layer.self_attn.v_proj.weight
        __UpperCAmelCase			   =     dataavec_layer.self_attn.v_proj.bias

        # self-attention output
        __UpperCAmelCase			   =     layer.attention.output
        assert (
            self_output.dense.weight.shape == dataavec_layer.self_attn.out_proj.weight.shape
        ), f'''Shape for self_output.dense.weight should be {dataavec_layer.self_attn.out_proj.weight.shape}'''
        __UpperCAmelCase			   =     dataavec_layer.self_attn.out_proj.weight
        __UpperCAmelCase			   =     dataavec_layer.self_attn.out_proj.bias
        __UpperCAmelCase			   =     dataavec_layer.self_attn_layer_norm.weight
        __UpperCAmelCase			   =     dataavec_layer.self_attn_layer_norm.bias

        # intermediate
        __UpperCAmelCase			   =     layer.intermediate
        assert (
            intermediate.dense.weight.shape == dataavec_layer.fca.weight.shape
        ), f'''Shape for intermediate.dense.weight should be {dataavec_layer.fca.weight.shape}'''
        __UpperCAmelCase			   =     dataavec_layer.fca.weight
        __UpperCAmelCase			   =     dataavec_layer.fca.bias

        # output
        __UpperCAmelCase			   =     layer.output
        assert (
            bert_output.dense.weight.shape == dataavec_layer.fca.weight.shape
        ), f'''Shape for bert_output.dense.weight should be {dataavec_layer.fca.weight.shape}'''
        __UpperCAmelCase			   =     dataavec_layer.fca.weight
        __UpperCAmelCase			   =     dataavec_layer.fca.bias
        __UpperCAmelCase			   =     dataavec_layer.final_layer_norm.weight
        __UpperCAmelCase			   =     dataavec_layer.final_layer_norm.bias
        # end of layer

    if classification_head:
        __UpperCAmelCase			   =     dataavec.model.classification_heads['''mnli'''].dense.weight
        __UpperCAmelCase			   =     dataavec.model.classification_heads['''mnli'''].dense.bias
        __UpperCAmelCase			   =     dataavec.model.classification_heads['''mnli'''].out_proj.weight
        __UpperCAmelCase			   =     dataavec.model.classification_heads['''mnli'''].out_proj.bias
    else:
        # LM Head
        __UpperCAmelCase			   =     dataavec_model.encoder.lm_head.dense.weight
        __UpperCAmelCase			   =     dataavec_model.encoder.lm_head.dense.bias
        __UpperCAmelCase			   =     dataavec_model.encoder.lm_head.layer_norm.weight
        __UpperCAmelCase			   =     dataavec_model.encoder.lm_head.layer_norm.bias
        __UpperCAmelCase			   =     dataavec_model.encoder.lm_head.weight
        __UpperCAmelCase			   =     dataavec_model.encoder.lm_head.bias

    # Let's check that we get the same results.
    __UpperCAmelCase			   =     dataavec.encode(SCREAMING_SNAKE_CASE ).unsqueeze(0 )  # batch of size 1

    __UpperCAmelCase			   =     model(SCREAMING_SNAKE_CASE )[0]
    if classification_head:
        __UpperCAmelCase			   =     dataavec.model.classification_heads['''mnli'''](dataavec.extract_features(SCREAMING_SNAKE_CASE ) )
    else:
        __UpperCAmelCase			   =     dataavec_model(SCREAMING_SNAKE_CASE )[0]
    print(our_output.shape    ,				their_output.shape )
    __UpperCAmelCase			   =     torch.max(torch.abs(our_output - their_output ) ).item()
    print(f'''max_absolute_diff = {max_absolute_diff}''' )  # ~ 1e-7
    __UpperCAmelCase			   =     torch.allclose(SCREAMING_SNAKE_CASE    ,				SCREAMING_SNAKE_CASE    ,				atol=1e-3 )
    print('''Do both models output the same tensors?'''    ,				'''🔥''' if success else '''💩''' )
    if not success:
        raise Exception('''Something went wRoNg''' )

    pathlib.Path(SCREAMING_SNAKE_CASE ).mkdir(parents=SCREAMING_SNAKE_CASE    ,				exist_ok=SCREAMING_SNAKE_CASE )
    print(f'''Saving model to {pytorch_dump_folder_path}''' )
    model.save_pretrained(SCREAMING_SNAKE_CASE )


if __name__ == "__main__":
       A_						:     Union[str, Any]			  =				argparse.ArgumentParser()
       # Required parameters
       parser.add_argument(
           '--checkpoint_path', default=None, type=str, required=True, help='Path the official PyTorch dump.'
       )
       parser.add_argument(
           '--pytorch_dump_folder_path', default=None, type=str, required=True, help='Path to the output PyTorch model.'
       )
       parser.add_argument(
           '--classification_head', action='store_true', help='Whether to convert a final classification head.'
       )
       A_						:     Optional[Any]			  =				parser.parse_args()
       convert_dataavec_checkpoint_to_pytorch(
           args.checkpoint_path, args.pytorch_dump_folder_path, args.classification_head
       )







import inspect
import unittest

from transformers import DPTConfig
from transformers.file_utils import is_torch_available, is_vision_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_vision, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
       import torch
       from torch import nn

       from transformers import MODEL_MAPPING, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTModel
       from transformers.models.dpt.modeling_dpt import DPT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
       from PIL import Image

       from transformers import DPTImageProcessor
class    A_				:


    '''simple docstring'''






    def __init__(self       , lowercase__       , lowercase__=2       , lowercase__=32       , lowercase__=16       , lowercase__=3       , lowercase__=True       , lowercase__=True       , lowercase__=32       , lowercase__=4       , lowercase__=[0, 1, 2, 3]       , lowercase__=4       , lowercase__=37       , lowercase__="gelu"       , lowercase__=0.1       , lowercase__=0.1       , lowercase__=0.02       , lowercase__=3       , lowercase__=False       , lowercase__=None       , )       -> Any:
        __UpperCAmelCase			   =     parent
        __UpperCAmelCase			   =     batch_size
        __UpperCAmelCase			   =     image_size
        __UpperCAmelCase			   =     patch_size
        __UpperCAmelCase			   =     num_channels
        __UpperCAmelCase			   =     is_training
        __UpperCAmelCase			   =     use_labels
        __UpperCAmelCase			   =     hidden_size
        __UpperCAmelCase			   =     num_hidden_layers
        __UpperCAmelCase			   =     backbone_out_indices
        __UpperCAmelCase			   =     num_attention_heads
        __UpperCAmelCase			   =     intermediate_size
        __UpperCAmelCase			   =     hidden_act
        __UpperCAmelCase			   =     hidden_dropout_prob
        __UpperCAmelCase			   =     attention_probs_dropout_prob
        __UpperCAmelCase			   =     initializer_range
        __UpperCAmelCase			   =     num_labels
        __UpperCAmelCase			   =     scope
        __UpperCAmelCase			   =     is_hybrid
        # sequence length of DPT = num_patches + 1 (we add 1 for the [CLS] token)
        __UpperCAmelCase			   =     (image_size // patch_size) ** 2
        __UpperCAmelCase			   =     num_patches + 1


    def        lowerCAmelCase_  (self					)       -> List[str]:
        __UpperCAmelCase			   =     floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]					)

        __UpperCAmelCase			   =     None
        if self.use_labels:
            __UpperCAmelCase			   =     ids_tensor([self.batch_size, self.image_size, self.image_size]       , self.num_labels					)

        __UpperCAmelCase			   =     self.get_config()

        return config, pixel_values, labels


    def        lowerCAmelCase_  (self					)       -> str:
        return DPTConfig(
            image_size=self.image_size       , patch_size=self.patch_size       , num_channels=self.num_channels       , hidden_size=self.hidden_size       , num_hidden_layers=self.num_hidden_layers       , backbone_out_indices=self.backbone_out_indices       , 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       , is_decoder=lowercase__       , initializer_range=self.initializer_range       , is_hybrid=self.is_hybrid       , )


    def        lowerCAmelCase_  (self       , lowercase__       , lowercase__       , lowercase__					)       -> Any:
        __UpperCAmelCase			   =     DPTModel(config=lowercase__					)
        model.to(lowercase__					)
        model.eval()
        __UpperCAmelCase			   =     model(lowercase__					)
        self.parent.assertEqual(result.last_hidden_state.shape       , (self.batch_size, self.seq_length, self.hidden_size)					)


    def        lowerCAmelCase_  (self       , lowercase__       , lowercase__       , lowercase__					)       -> List[Any]:
        __UpperCAmelCase			   =     self.num_labels
        __UpperCAmelCase			   =     DPTForDepthEstimation(lowercase__					)
        model.to(lowercase__					)
        model.eval()
        __UpperCAmelCase			   =     model(lowercase__					)
        self.parent.assertEqual(result.predicted_depth.shape       , (self.batch_size, self.image_size, self.image_size)					)


    def        lowerCAmelCase_  (self       , lowercase__       , lowercase__       , lowercase__					)       -> str:
        __UpperCAmelCase			   =     self.num_labels
        __UpperCAmelCase			   =     DPTForSemanticSegmentation(lowercase__					)
        model.to(lowercase__					)
        model.eval()
        __UpperCAmelCase			   =     model(lowercase__       , labels=lowercase__					)
        self.parent.assertEqual(
            result.logits.shape       , (self.batch_size, self.num_labels, self.image_size, self.image_size)					)






    def        lowerCAmelCase_  (self					)       -> Union[str, Any]:
        __UpperCAmelCase			   =     self.prepare_config_and_inputs()
        __UpperCAmelCase   ,       __UpperCAmelCase   ,       __UpperCAmelCase			   =     config_and_inputs
        __UpperCAmelCase			   =     {'''pixel_values''': pixel_values}
        return config, inputs_dict






@require_torch
class    A_				( _a	,       _a	,       unittest.TestCase  ):


    '''simple docstring'''






    a__       							=    (DPTModel, DPTForDepthEstimation, DPTForSemanticSegmentation) if is_torch_available() else ()
    a__       							=    (
        {
            "depth-estimation": DPTForDepthEstimation,
            "feature-extraction": DPTModel,
            "image-segmentation": DPTForSemanticSegmentation,
        }
        if is_torch_available()
        else {}
    )

    a__       							=    False
    a__       							=    False
    a__       							=    False


    def        lowerCAmelCase_  (self					)       -> Tuple:
        __UpperCAmelCase			   =     DPTModelTester(self					)
        __UpperCAmelCase			   =     ConfigTester(self       , config_class=lowercase__       , has_text_modality=lowercase__       , hidden_size=37					)


    def        lowerCAmelCase_  (self					)       -> Dict:
        self.config_tester.run_common_tests()


    @unittest.skip(reason='''DPT does not use inputs_embeds'''					)
    def        lowerCAmelCase_  (self					)       -> int:
        pass


    def        lowerCAmelCase_  (self					)       -> Any:
        __UpperCAmelCase   ,       __UpperCAmelCase			   =     self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
            __UpperCAmelCase			   =     model_class(lowercase__					)
            self.assertIsInstance(model.get_input_embeddings()       , (nn.Module)					)
            __UpperCAmelCase			   =     model.get_output_embeddings()
            self.assertTrue(x is None or isinstance(lowercase__       , nn.Linear					)					)


    def        lowerCAmelCase_  (self					)       -> int:
        __UpperCAmelCase   ,       __UpperCAmelCase			   =     self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
            __UpperCAmelCase			   =     model_class(lowercase__					)
            __UpperCAmelCase			   =     inspect.signature(model.forward					)
            # signature.parameters is an OrderedDict => so arg_names order is deterministic
            __UpperCAmelCase			   =     [*signature.parameters.keys()]

            __UpperCAmelCase			   =     ['''pixel_values''']
            self.assertListEqual(arg_names[:1]       , lowercase__					)


    def        lowerCAmelCase_  (self					)       -> Optional[int]:
        __UpperCAmelCase			   =     self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_model(*lowercase__					)


    def        lowerCAmelCase_  (self					)       -> Optional[Any]:
        __UpperCAmelCase			   =     self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_depth_estimation(*lowercase__					)


    def        lowerCAmelCase_  (self					)       -> int:
        __UpperCAmelCase			   =     self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_semantic_segmentation(*lowercase__					)


    def        lowerCAmelCase_  (self					)       -> Any:
        for model_class in self.all_model_classes:
            if model_class.__name__ == "DPTForDepthEstimation":
                continue

            __UpperCAmelCase   ,       __UpperCAmelCase			   =     self.model_tester.prepare_config_and_inputs_for_common()
            __UpperCAmelCase			   =     True

            if model_class in get_values(lowercase__					):
                continue

            __UpperCAmelCase			   =     model_class(lowercase__					)
            model.to(lowercase__					)
            model.train()
            __UpperCAmelCase			   =     self._prepare_for_class(lowercase__       , lowercase__       , return_labels=lowercase__					)
            __UpperCAmelCase			   =     model(**lowercase__					).loss
            loss.backward()


    def        lowerCAmelCase_  (self					)       -> Tuple:
        for model_class in self.all_model_classes:
            if model_class.__name__ == "DPTForDepthEstimation":
                continue

            __UpperCAmelCase   ,       __UpperCAmelCase			   =     self.model_tester.prepare_config_and_inputs_for_common()
            __UpperCAmelCase			   =     False
            __UpperCAmelCase			   =     True

            if model_class in get_values(lowercase__					) or not model_class.supports_gradient_checkpointing:
                continue
            __UpperCAmelCase			   =     model_class(lowercase__					)
            model.to(lowercase__					)
            model.gradient_checkpointing_enable()
            model.train()
            __UpperCAmelCase			   =     self._prepare_for_class(lowercase__       , lowercase__       , return_labels=lowercase__					)
            __UpperCAmelCase			   =     model(**lowercase__					).loss
            loss.backward()


    def        lowerCAmelCase_  (self					)       -> Union[str, Any]:
        __UpperCAmelCase   ,       __UpperCAmelCase			   =     self.model_tester.prepare_config_and_inputs_for_common()

        __UpperCAmelCase			   =     _config_zero_init(lowercase__					)
        for model_class in self.all_model_classes:
            __UpperCAmelCase			   =     model_class(config=lowercase__					)
            # Skip the check for the backbone
            __UpperCAmelCase			   =     []
            for name, module in model.named_modules():
                if module.__class__.__name__ == "DPTViTHybridEmbeddings":
                    __UpperCAmelCase			   =     [F'''{name}.{key}''' for key in module.state_dict().keys()]
                    break

            for name, param in model.named_parameters():
                if param.requires_grad:
                    if name in backbone_params:
                        continue
                    self.assertIn(
                        ((param.data.mean() * 1E9).round() / 1E9).item()       , [0.0, 1.0]       , msg=F'''Parameter {name} of model {model_class} seems not properly initialized'''       , )


    @unittest.skip('''Will be fixed soon by reducing the size of the model used for common tests.'''					)
    def        lowerCAmelCase_  (self					)       -> int:
        pass






    @slow
    def        lowerCAmelCase_  (self					)       -> List[str]:
        for model_name in DPT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
            __UpperCAmelCase			   =     DPTModel.from_pretrained(lowercase__					)
            self.assertIsNotNone(lowercase__					)






def  __a    (				) ->       Any:






    '''simple docstring'''
    __UpperCAmelCase			   =     Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png''' )
    return image
@require_torch
@require_vision
@slow
class    A_				( unittest.TestCase  ):


    '''simple docstring'''






    def        lowerCAmelCase_  (self					)       -> Any:
        __UpperCAmelCase			   =     DPTImageProcessor.from_pretrained('''Intel/dpt-large'''					)
        __UpperCAmelCase			   =     DPTForDepthEstimation.from_pretrained('''Intel/dpt-large'''					).to(lowercase__					)

        __UpperCAmelCase			   =     prepare_img()
        __UpperCAmelCase			   =     image_processor(images=lowercase__       , return_tensors='''pt'''					).to(lowercase__					)

        # forward pass
        with torch.no_grad():
            __UpperCAmelCase			   =     model(**lowercase__					)
            __UpperCAmelCase			   =     outputs.predicted_depth

        # verify the predicted depth
        __UpperCAmelCase			   =     torch.Size((1, 384, 384)					)
        self.assertEqual(predicted_depth.shape       , lowercase__					)

        __UpperCAmelCase			   =     torch.tensor(
            [[6.3199, 6.3629, 6.4148], [6.3850, 6.3615, 6.4166], [6.3519, 6.3176, 6.3575]]					).to(lowercase__					)

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


    def        lowerCAmelCase_  (self					)       -> Tuple:
        __UpperCAmelCase			   =     DPTImageProcessor.from_pretrained('''Intel/dpt-large-ade'''					)
        __UpperCAmelCase			   =     DPTForSemanticSegmentation.from_pretrained('''Intel/dpt-large-ade'''					).to(lowercase__					)

        __UpperCAmelCase			   =     prepare_img()
        __UpperCAmelCase			   =     image_processor(images=lowercase__       , return_tensors='''pt'''					).to(lowercase__					)

        # forward pass
        with torch.no_grad():
            __UpperCAmelCase			   =     model(**lowercase__					)

        # verify the logits
        __UpperCAmelCase			   =     torch.Size((1, 150, 480, 480)					)
        self.assertEqual(outputs.logits.shape       , lowercase__					)

        __UpperCAmelCase			   =     torch.tensor(
            [[4.0480, 4.2420, 4.4360], [4.3124, 4.5693, 4.8261], [4.5768, 4.8965, 5.2163]]					).to(lowercase__					)

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






    def        lowerCAmelCase_  (self					)       -> str:
        __UpperCAmelCase			   =     DPTImageProcessor.from_pretrained('''Intel/dpt-large-ade'''					)
        __UpperCAmelCase			   =     DPTForSemanticSegmentation.from_pretrained('''Intel/dpt-large-ade'''					).to(lowercase__					)

        __UpperCAmelCase			   =     prepare_img()
        __UpperCAmelCase			   =     image_processor(images=lowercase__       , return_tensors='''pt'''					).to(lowercase__					)

        # forward pass
        with torch.no_grad():
            __UpperCAmelCase			   =     model(**lowercase__					)

        __UpperCAmelCase			   =     outputs.logits.detach().cpu()

        __UpperCAmelCase			   =     image_processor.post_process_semantic_segmentation(outputs=lowercase__       , target_sizes=[(500, 300)]					)
        __UpperCAmelCase			   =     torch.Size((500, 300)					)
        self.assertEqual(segmentation[0].shape       , lowercase__					)

        __UpperCAmelCase			   =     image_processor.post_process_semantic_segmentation(outputs=lowercase__					)
        __UpperCAmelCase			   =     torch.Size((480, 480)					)
        self.assertEqual(segmentation[0].shape       , lowercase__					)




