


from __future__ import annotations

import unittest

from transformers import DebertaVaConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
 import tensorflow as tf

 from transformers import (
     TFDebertaVaForMaskedLM,
     TFDebertaVaForQuestionAnswering,
     TFDebertaVaForSequenceClassification,
     TFDebertaVaForTokenClassification,
     TFDebertaVaModel,
 )


class 		_SCREAMING_SNAKE_CASE     :


     def __init__(  self							,					A_							,					A_=13							,					A_=7							,					A_=True							,					A_=True							,					A_=True							,					A_=True							,					A_=99							,					A_=32							,					A_=2							,					A_=4							,					A_=37							,					A_="gelu"							,					A_=0.1							,					A_=0.1							,					A_=5_12							,					A_=16							,					A_=2							,					A_=0.0_2							,					A_=False							,					A_=True							,					A_="None"							,					A_=3							,					A_=4							,					A_=None							,					):
       _UpperCAmelCase		:							Optional[Any]							=     parent
       _UpperCAmelCase		:							List[Any]							=     batch_size
       _UpperCAmelCase		:							List[Any]							=     seq_length
       _UpperCAmelCase		:							Optional[Any]							=     is_training
       _UpperCAmelCase		:							List[str]							=     use_input_mask
       _UpperCAmelCase		:							str							=     use_token_type_ids
       _UpperCAmelCase		:							List[str]							=     use_labels
       _UpperCAmelCase		:							Dict							=     vocab_size
       _UpperCAmelCase		:							Optional[int]							=     hidden_size
       _UpperCAmelCase		:							List[str]							=     num_hidden_layers
       _UpperCAmelCase		:							Optional[Any]							=     num_attention_heads
       _UpperCAmelCase		:							str							=     intermediate_size
       _UpperCAmelCase		:							Dict							=     hidden_act
       _UpperCAmelCase		:							Any							=     hidden_dropout_prob
       _UpperCAmelCase		:							List[str]							=     attention_probs_dropout_prob
       _UpperCAmelCase		:							Any							=     max_position_embeddings
       _UpperCAmelCase		:							Optional[Any]							=     type_vocab_size
       _UpperCAmelCase		:							Dict							=     type_sequence_label_size
       _UpperCAmelCase		:							int							=     initializer_range
       _UpperCAmelCase		:							int							=     num_labels
       _UpperCAmelCase		:							int							=     num_choices
       _UpperCAmelCase		:							Union[str, Any]							=     relative_attention
       _UpperCAmelCase		:							Union[str, Any]							=     position_biased_input
       _UpperCAmelCase		:							List[str]							=     pos_att_type
       _UpperCAmelCase		:							List[str]							=     scope


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							Optional[Any]							=     ids_tensor([self.batch_size, self.seq_length]							,					self.vocab_size    )

       _UpperCAmelCase		:							Optional[Any]							=     None
       if self.use_input_mask:
         _UpperCAmelCase		:							int							=     random_attention_mask([self.batch_size, self.seq_length]    )

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

       _UpperCAmelCase		:							Tuple							=     None
       _UpperCAmelCase		:							Any							=     None
       _UpperCAmelCase		:							int							=     None
       if self.use_labels:
         _UpperCAmelCase		:							List[Any]							=     ids_tensor([self.batch_size]							,					self.type_sequence_label_size    )
         _UpperCAmelCase		:							List[Any]							=     ids_tensor([self.batch_size, self.seq_length]							,					self.num_labels    )

       _UpperCAmelCase		:							Tuple							=     DebertaVaConfig(
           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							,					relative_attention=self.relative_attention							,					position_biased_input=self.position_biased_input							,					initializer_range=self.initializer_range							,					return_dict=A_							,					)

       return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels


     def        __snake_case(  self							,					A_							,					A_							,					A_							,					A_							,					A_							,					A_							,					A_    ):
       _UpperCAmelCase		:							Optional[Any]							=     TFDebertaVaModel(config=A_    )
       _UpperCAmelCase		:							Union[str, Any]							=     {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}

       _UpperCAmelCase		:							int							=     [input_ids, input_mask]
       _UpperCAmelCase		:							Any							=     model(A_    )

       _UpperCAmelCase		:							Optional[Any]							=     model(A_    )

       self.parent.assertEqual(result.last_hidden_state.shape							,					(self.batch_size, self.seq_length, self.hidden_size)    )


     def        __snake_case(  self							,					A_							,					A_							,					A_							,					A_							,					A_							,					A_							,					A_    ):
       _UpperCAmelCase		:							Optional[Any]							=     TFDebertaVaForMaskedLM(config=A_    )
       _UpperCAmelCase		:							Tuple							=     {
           """input_ids""": input_ids,
           """attention_mask""": input_mask,
           """token_type_ids""": token_type_ids,
       }
       _UpperCAmelCase		:							Any							=     model(A_    )
       self.parent.assertEqual(result.logits.shape							,					(self.batch_size, self.seq_length, self.vocab_size)    )


     def        __snake_case(  self							,					A_							,					A_							,					A_							,					A_							,					A_							,					A_							,					A_    ):
       _UpperCAmelCase		:							Optional[Any]							=     self.num_labels
       _UpperCAmelCase		:							Tuple							=     TFDebertaVaForSequenceClassification(config=A_    )
       _UpperCAmelCase		:							List[Any]							=     {
           """input_ids""": input_ids,
           """attention_mask""": input_mask,
           """token_type_ids""": token_type_ids,
       }

       _UpperCAmelCase		:							str							=     model(A_    )
       self.parent.assertEqual(result.logits.shape							,					(self.batch_size, self.num_labels)    )


     def        __snake_case(  self							,					A_							,					A_							,					A_							,					A_							,					A_							,					A_							,					A_    ):
       _UpperCAmelCase		:							Any							=     self.num_labels
       _UpperCAmelCase		:							int							=     TFDebertaVaForTokenClassification(config=A_    )
       _UpperCAmelCase		:							Any							=     {
           """input_ids""": input_ids,
           """attention_mask""": input_mask,
           """token_type_ids""": token_type_ids,
       }
       _UpperCAmelCase		:							Any							=     model(A_    )
       self.parent.assertEqual(result.logits.shape							,					(self.batch_size, self.seq_length, self.num_labels)    )


     def        __snake_case(  self							,					A_							,					A_							,					A_							,					A_							,					A_							,					A_							,					A_    ):
       _UpperCAmelCase		:							Tuple							=     TFDebertaVaForQuestionAnswering(config=A_    )
       _UpperCAmelCase		:							Optional[Any]							=     {
           """input_ids""": input_ids,
           """attention_mask""": input_mask,
           """token_type_ids""": token_type_ids,
       }

       _UpperCAmelCase		:							List[Any]							=     model(A_    )
       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        __snake_case(  self    ):
       _UpperCAmelCase		:							int							=     self.prepare_config_and_inputs()
       (
           (
           _UpperCAmelCase
       ),(
           _UpperCAmelCase
       ),(
           _UpperCAmelCase
       ),(
           _UpperCAmelCase
       ),(
           _UpperCAmelCase
       ),(
           _UpperCAmelCase
       ),(
           _UpperCAmelCase
       ),
       )		:							str							=     config_and_inputs
       _UpperCAmelCase		:							int							=     {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
       return config, inputs_dict


@require_tf
class 		_SCREAMING_SNAKE_CASE     (						A							,	A							,	unittest.TestCase     ):
     __SCREAMING_SNAKE_CASE     					=    (
         (
             TFDebertaVaModel,
             TFDebertaVaForMaskedLM,
             TFDebertaVaForQuestionAnswering,
             TFDebertaVaForSequenceClassification,
             TFDebertaVaForTokenClassification,
         )
         if is_tf_available()
         else ()
     )
     __SCREAMING_SNAKE_CASE     					=    (
         {
             '''feature-extraction''': TFDebertaVaModel,
             '''fill-mask''': TFDebertaVaForMaskedLM,
             '''question-answering''': TFDebertaVaForQuestionAnswering,
             '''text-classification''': TFDebertaVaForSequenceClassification,
             '''token-classification''': TFDebertaVaForTokenClassification,
             '''zero-shot''': TFDebertaVaForSequenceClassification,
         }
         if is_tf_available()
         else {}
     )

     __SCREAMING_SNAKE_CASE     					=    False
     __SCREAMING_SNAKE_CASE     					=    False


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							int							=     TFDebertaVaModelTester(self    )
       _UpperCAmelCase		:							Union[str, Any]							=     ConfigTester(self							,					config_class=A_							,					hidden_size=37    )


     def        __snake_case(  self    ):
       self.config_tester.run_common_tests()


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							Union[str, Any]							=     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*A_    )


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							int							=     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_masked_lm(*A_    )


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							List[str]							=     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_question_answering(*A_    )


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							str							=     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_sequence_classification(*A_    )


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							Optional[int]							=     self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_token_classification(*A_    )




     @slow
     def        __snake_case(  self    ):
       _UpperCAmelCase		:							Any							=     TFDebertaVaModel.from_pretrained("""kamalkraj/deberta-v2-xlarge"""    )
       self.assertIsNotNone(A_    )


@require_tf
class 		_SCREAMING_SNAKE_CASE     (						unittest.TestCase     ):


     @unittest.skip(reason="""Model not available yet"""    )
     def        __snake_case(  self    ):
       pass




     @slow
     def        __snake_case(  self    ):
       _UpperCAmelCase		:							Optional[Any]							=     TFDebertaVaModel.from_pretrained("""kamalkraj/deberta-v2-xlarge"""    )
       _UpperCAmelCase		:							Optional[Any]							=     tf.constant([[0, 3_14_14, 2_32, 3_28, 7_40, 11_40, 1_26_95, 69, 4_60_78, 15_88, 2]]    )
       _UpperCAmelCase		:							Dict							=     tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]    )
       _UpperCAmelCase		:							Dict							=     model(A_							,					attention_mask=A_    )[0]

       _UpperCAmelCase		:							Union[str, Any]							=     tf.constant(
           [[[0.2_3_5_6, 0.1_9_4_8, 0.0_3_6_9], [-0.1_0_6_3, 0.3_5_8_6, -0.5_1_5_2], [-0.6_3_9_9, -0.0_2_5_9, -0.2_5_2_5]]]    )
       tf.debugging.assert_near(output[:, 1:4, 1:4]							,					A_							,					atol=1e-4    )









import random
import unittest

import numpy as np
import torch

from diffusers import (
    DPMSolverMultistepScheduler,
    EulerAncestralDiscreteScheduler,
    EulerDiscreteScheduler,
    LMSDiscreteScheduler,
    OnnxStableDiffusionUpscalePipeline,
    PNDMScheduler,
)
from diffusers.utils import floats_tensor
from diffusers.utils.testing_utils import (
    is_onnx_available,
    load_image,
    nightly,
    require_onnxruntime,
    require_torch_gpu,
)

from ..test_pipelines_onnx_common import OnnxPipelineTesterMixin


if is_onnx_available():
 import onnxruntime as ort


class 		_SCREAMING_SNAKE_CASE     (						A							,	unittest.TestCase     ):
     # TODO: is there an appropriate internal test set?
     __SCREAMING_SNAKE_CASE     					=    '''ssube/stable-diffusion-x4-upscaler-onnx'''


     def        __snake_case(  self							,					A_=0    ):
       _UpperCAmelCase		:							List[Any]							=     floats_tensor((1, 3, 1_28, 1_28)							,					rng=random.Random(A_    )    )
       _UpperCAmelCase		:							Any							=     torch.manual_seed(A_    )
       _UpperCAmelCase		:							List[Any]							=     {
           """prompt""": """A painting of a squirrel eating a burger""",
           """image""": image,
           """generator""": generator,
           """num_inference_steps""": 3,
           """guidance_scale""": 7.5,
           """output_type""": """numpy""",
       }
       return inputs


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							Optional[int]							=     OnnxStableDiffusionUpscalePipeline.from_pretrained(self.hub_checkpoint							,					provider="""CPUExecutionProvider"""    )
       pipe.set_progress_bar_config(disable=A_    )

       _UpperCAmelCase		:							Optional[Any]							=     self.get_dummy_inputs()
       _UpperCAmelCase		:							List[str]							=     pipe(**A_    ).images
       _UpperCAmelCase		:							Tuple							=     image[0, -3:, -3:, -1].flatten()

       # started as 128, should now be 512
       assert image.shape == (1, 5_12, 5_12, 3)
       _UpperCAmelCase		:							Any							=     np.array(
           [0.6_9_7_4_7_8_2, 0.6_8_9_0_2_0_9_3, 0.7_0_1_3_5_8_8_5, 0.7_5_8_3_6_1_8, 0.7_8_0_4_5_4_5, 0.7_8_5_4_9_1_2, 0.7_8_6_6_7_4_2_6, 0.7_8_7_4_3_8_6_3, 0.7_8_0_7_0_2_2_3]    )
       assert np.abs(image_slice - expected_slice    ).max() < 1e-1


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							int							=     OnnxStableDiffusionUpscalePipeline.from_pretrained(self.hub_checkpoint							,					provider="""CPUExecutionProvider"""    )
       _UpperCAmelCase		:							Tuple							=     PNDMScheduler.from_config(pipe.scheduler.config							,					skip_prk_steps=A_    )
       pipe.set_progress_bar_config(disable=A_    )

       _UpperCAmelCase		:							Optional[Any]							=     self.get_dummy_inputs()
       _UpperCAmelCase		:							Optional[Any]							=     pipe(**A_    ).images
       _UpperCAmelCase		:							Dict							=     image[0, -3:, -3:, -1]

       assert image.shape == (1, 5_12, 5_12, 3)
       _UpperCAmelCase		:							Optional[Any]							=     np.array(
           [0.6_8_9_8_8_9_2, 0.5_9_2_4_0_5_5_6, 0.5_2_4_9_9_5_2_7, 0.5_8_8_6_6_2_1_5, 0.5_2_2_5_8_2_3_5, 0.5_2_5_7_2_7_1_5, 0.6_2_4_1_4_4_7_3, 0.6_1_7_4_3_8_7, 0.6_2_1_4_9_6_4]    )
       assert np.abs(image_slice.flatten() - expected_slice    ).max() < 1e-1


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							List[str]							=     OnnxStableDiffusionUpscalePipeline.from_pretrained(self.hub_checkpoint							,					provider="""CPUExecutionProvider"""    )
       _UpperCAmelCase		:							Dict							=     DPMSolverMultistepScheduler.from_config(pipe.scheduler.config    )
       pipe.set_progress_bar_config(disable=A_    )

       _UpperCAmelCase		:							str							=     self.get_dummy_inputs()
       _UpperCAmelCase		:							List[Any]							=     pipe(**A_    ).images
       _UpperCAmelCase		:							Any							=     image[0, -3:, -3:, -1]

       assert image.shape == (1, 5_12, 5_12, 3)
       _UpperCAmelCase		:							Tuple							=     np.array(
           [0.7_6_5_9_2_7_8, 0.7_6_4_3_7_6_6_4, 0.7_5_5_7_9_1_0_7, 0.7_6_9_1_1_1_6, 0.7_7_6_6_6_9_8_6, 0.7_7_2_7_6_7_2, 0.7_7_5_8_6_6_4, 0.7_8_1_2_2_2_6, 0.7_6_9_4_2_5_1_5]    )

       assert np.abs(image_slice.flatten() - expected_slice    ).max() < 1e-1


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							Tuple							=     OnnxStableDiffusionUpscalePipeline.from_pretrained(self.hub_checkpoint							,					provider="""CPUExecutionProvider"""    )
       _UpperCAmelCase		:							Dict							=     EulerDiscreteScheduler.from_config(pipe.scheduler.config    )
       pipe.set_progress_bar_config(disable=A_    )

       _UpperCAmelCase		:							Union[str, Any]							=     self.get_dummy_inputs()
       _UpperCAmelCase		:							Union[str, Any]							=     pipe(**A_    ).images
       _UpperCAmelCase		:							int							=     image[0, -3:, -3:, -1]

       assert image.shape == (1, 5_12, 5_12, 3)
       _UpperCAmelCase		:							List[Any]							=     np.array(
           [0.6_9_7_4_7_8_2, 0.6_8_9_0_2_0_9_3, 0.7_0_1_3_5_8_8_5, 0.7_5_8_3_6_1_8, 0.7_8_0_4_5_4_5, 0.7_8_5_4_9_1_2, 0.7_8_6_6_7_4_2_6, 0.7_8_7_4_3_8_6_3, 0.7_8_0_7_0_2_2_3]    )
       assert np.abs(image_slice.flatten() - expected_slice    ).max() < 1e-1




     def        __snake_case(  self    ):
       _UpperCAmelCase		:							List[str]							=     OnnxStableDiffusionUpscalePipeline.from_pretrained(self.hub_checkpoint							,					provider="""CPUExecutionProvider"""    )
       _UpperCAmelCase		:							List[Any]							=     EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config    )
       pipe.set_progress_bar_config(disable=A_    )

       _UpperCAmelCase		:							Union[str, Any]							=     self.get_dummy_inputs()
       _UpperCAmelCase		:							str							=     pipe(**A_    ).images
       _UpperCAmelCase		:							Optional[int]							=     image[0, -3:, -3:, -1]

       assert image.shape == (1, 5_12, 5_12, 3)
       _UpperCAmelCase		:							Tuple							=     np.array(
           [0.7_7_4_2_4_4_9_6, 0.7_7_3_6_0_1, 0.7_6_4_5_2_8_8, 0.7_7_6_9_5_9_8, 0.7_7_7_2_7_3_9, 0.7_7_3_8_6_8_8, 0.7_8_1_8_7_2_3_3, 0.7_7_8_7_9_5_8_4, 0.7_6_7_0_4_3]    )

       assert np.abs(image_slice.flatten() - expected_slice    ).max() < 1e-1


@nightly
@require_onnxruntime
@require_torch_gpu
class 		_SCREAMING_SNAKE_CASE     (						unittest.TestCase     ):


     @property
     def        __snake_case(  self    ):
       return (
           "CUDAExecutionProvider",
           {
               "gpu_mem_limit": "15000000000",  # 15GB
               "arena_extend_strategy": "kSameAsRequested",
           },
       )


     @property
     def        __snake_case(  self    ):
       _UpperCAmelCase		:							List[str]							=     ort.SessionOptions()
       _UpperCAmelCase		:							Union[str, Any]							=     False
       return options


     def        __snake_case(  self    ):
       _UpperCAmelCase		:							List[Any]							=     load_image(
           """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"""
           """/img2img/sketch-mountains-input.jpg"""    )
       _UpperCAmelCase		:							Any							=     init_image.resize((1_28, 1_28)    )
       # using the PNDM scheduler by default
       _UpperCAmelCase		:							Union[str, Any]							=     OnnxStableDiffusionUpscalePipeline.from_pretrained(
           """ssube/stable-diffusion-x4-upscaler-onnx"""							,					provider=self.gpu_provider							,					sess_options=self.gpu_options							,					)
       pipe.set_progress_bar_config(disable=A_    )

       _UpperCAmelCase		:							Union[str, Any]							=     """A fantasy landscape, trending on artstation"""

       _UpperCAmelCase		:							Tuple							=     torch.manual_seed(0    )
       _UpperCAmelCase		:							Tuple							=     pipe(
           prompt=A_							,					image=A_							,					guidance_scale=7.5							,					num_inference_steps=10							,					generator=A_							,					output_type="""np"""							,					)
       _UpperCAmelCase		:							Dict							=     output.images
       _UpperCAmelCase		:							List[Any]							=     images[0, 2_55:2_58, 3_83:3_86, -1]

       assert images.shape == (1, 5_12, 5_12, 3)
       _UpperCAmelCase		:							List[str]							=     np.array([0.4_8_8_3, 0.4_9_4_7, 0.4_9_8_0, 0.4_9_7_5, 0.4_9_8_2, 0.4_9_8_0, 0.5_0_0_0, 0.5_0_0_6, 0.4_9_7_2]    )
       # TODO: lower the tolerance after finding the cause of onnxruntime reproducibility issues

       assert np.abs(image_slice.flatten() - expected_slice    ).max() < 2e-2




     def        __snake_case(  self    ):
       _UpperCAmelCase		:							List[str]							=     load_image(
           """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"""
           """/img2img/sketch-mountains-input.jpg"""    )
       _UpperCAmelCase		:							Optional[int]							=     init_image.resize((1_28, 1_28)    )
       _UpperCAmelCase		:							Optional[int]							=     LMSDiscreteScheduler.from_pretrained(
           """ssube/stable-diffusion-x4-upscaler-onnx"""							,					subfolder="""scheduler"""    )
       _UpperCAmelCase		:							Union[str, Any]							=     OnnxStableDiffusionUpscalePipeline.from_pretrained(
           """ssube/stable-diffusion-x4-upscaler-onnx"""							,					scheduler=A_							,					provider=self.gpu_provider							,					sess_options=self.gpu_options							,					)
       pipe.set_progress_bar_config(disable=A_    )

       _UpperCAmelCase		:							Union[str, Any]							=     """A fantasy landscape, trending on artstation"""

       _UpperCAmelCase		:							str							=     torch.manual_seed(0    )
       _UpperCAmelCase		:							Optional[int]							=     pipe(
           prompt=A_							,					image=A_							,					guidance_scale=7.5							,					num_inference_steps=20							,					generator=A_							,					output_type="""np"""							,					)
       _UpperCAmelCase		:							Dict							=     output.images
       _UpperCAmelCase		:							Dict							=     images[0, 2_55:2_58, 3_83:3_86, -1]

       assert images.shape == (1, 5_12, 5_12, 3)
       _UpperCAmelCase		:							Optional[Any]							=     np.array(
           [0.5_0_1_7_3_7_5_3, 0.5_0_2_2_3_3_5_6, 0.5_0_2_0_3_9, 0.5_0_2_3_3_0_3_6, 0.5_0_2_3_7_2_5, 0.5_0_2_2_6_0_1, 0.5_0_1_8_7_5_8, 0.5_0_2_3_4_0_8_5, 0.5_0_2_4_1_5_6_6]    )
       # TODO: lower the tolerance after finding the cause of onnxruntime reproducibility issues

       assert np.abs(image_slice.flatten() - expected_slice    ).max() < 2e-2





