



"""simple docstring"""







import inspect
from typing import Callable, List, Optional, Union

import torch
from transformers import (
    CLIPImageProcessor,
    CLIPTextModel,
    CLIPTokenizer,
    WhisperForConditionalGeneration,
    WhisperProcessor,
)

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    DiffusionPipeline,
    LMSDiscreteScheduler,
    PNDMScheduler,
    UNetaDConditionModel,
)
from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion import StableDiffusionPipelineOutput
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
from diffusers.utils import logging


lowercase__		:				Any          =	logging.get_logger(__name__)  # pylint: disable=invalid-name







class       UpperCamelCase__   (	lowercase_  ):




      """simple docstring"""




      def __init__(      self				:      Dict    ,			SCREAMING_SNAKE_CASE_				:      WhisperForConditionalGeneration    ,			SCREAMING_SNAKE_CASE_				:      WhisperProcessor    ,			SCREAMING_SNAKE_CASE_				:      AutoencoderKL    ,			SCREAMING_SNAKE_CASE_				:      CLIPTextModel    ,			SCREAMING_SNAKE_CASE_				:      CLIPTokenizer    ,			SCREAMING_SNAKE_CASE_				:      UNetaDConditionModel    ,			SCREAMING_SNAKE_CASE_				:      Union[DDIMScheduler, PNDMScheduler, LMSDiscreteScheduler]    ,			SCREAMING_SNAKE_CASE_				:      StableDiffusionSafetyChecker    ,			SCREAMING_SNAKE_CASE_				:      CLIPImageProcessor    ,			):
        super().__init__()

        if safety_checker is None:
          logger.warning(
              F"You have disabled the safety checker for {self.__class__} by passing `safety_checker=None`. Ensure"
              ' that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered'
              ' results in services or applications open to the public. Both the diffusers team and Hugging Face'
              ' strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling'
              ' it only for use-cases that involve analyzing network behavior or auditing its results. For more'
              ' information, please have a look at https://github.com/huggingface/diffusers/pull/254 .'       )

        self.register_modules(
            speech_model=__UpperCamelCase    ,			speech_processor=__UpperCamelCase    ,			vae=__UpperCamelCase    ,			text_encoder=__UpperCamelCase    ,			tokenizer=__UpperCamelCase    ,			unet=__UpperCamelCase    ,			scheduler=__UpperCamelCase    ,			feature_extractor=__UpperCamelCase    ,			)



      def      SCREAMING_SNAKE_CASE__ (      self				:      Any    ,			SCREAMING_SNAKE_CASE_				:      Optional[Union[str, int]] = "auto"       ):
        if slice_size == "auto":
          lowerCAmelCase_   :				int								= self.unet.config.attention_head_dim // 2
        self.unet.set_attention_slice(__UpperCamelCase       )



      def      SCREAMING_SNAKE_CASE__ (      self				:      Tuple       ):
        self.enable_attention_slicing(__UpperCamelCase       )





      @torch.no_grad()
      def __call__(      self				:      Optional[Any]    ,			SCREAMING_SNAKE_CASE_				:      Any    ,			SCREAMING_SNAKE_CASE_				:      Dict=1_6_0_0_0    ,			SCREAMING_SNAKE_CASE_				:      int = 5_1_2    ,			SCREAMING_SNAKE_CASE_				:      int = 5_1_2    ,			SCREAMING_SNAKE_CASE_				:      int = 5_0    ,			SCREAMING_SNAKE_CASE_				:      float = 7.5    ,			SCREAMING_SNAKE_CASE_				:      Optional[Union[str, List[str]]] = None    ,			SCREAMING_SNAKE_CASE_				:      Optional[int] = 1    ,			SCREAMING_SNAKE_CASE_				:      float = 0.0    ,			SCREAMING_SNAKE_CASE_				:      Optional[torch.Generator] = None    ,			SCREAMING_SNAKE_CASE_				:      Optional[torch.FloatTensor] = None    ,			SCREAMING_SNAKE_CASE_				:      Optional[str] = "pil"    ,			SCREAMING_SNAKE_CASE_				:      bool = True    ,			SCREAMING_SNAKE_CASE_				:      Optional[Callable[[int, int, torch.FloatTensor], None]] = None    ,			SCREAMING_SNAKE_CASE_				:      int = 1    ,			**SCREAMING_SNAKE_CASE_				:      Dict    ,			):
        lowerCAmelCase_   :				Union[str, Any]								= self.speech_processor.feature_extractor(
            __UpperCamelCase    ,			return_tensors='pt'    ,			sampling_rate=__UpperCamelCase       ).input_features.to(self.device       )
        lowerCAmelCase_   :				Optional[int]								= self.speech_model.generate(__UpperCamelCase    ,			max_length=4_8_0_0_0_0       )

        lowerCAmelCase_   :				Dict								= self.speech_processor.tokenizer.batch_decode(__UpperCamelCase    ,			skip_special_tokens=__UpperCamelCase    ,			normalize=__UpperCamelCase       )[
            0
        ]

        if isinstance(__UpperCamelCase    ,			__UpperCamelCase       ):
          lowerCAmelCase_   :				str								= 1
        elif isinstance(__UpperCamelCase    ,			__UpperCamelCase       ):
          lowerCAmelCase_   :				Optional[int]								= len(__UpperCamelCase       )
        else:
          raise ValueError(F"`prompt` has to be of type `str` or `list` but is {type(__UpperCamelCase       )}"       )

        if height % 8 != 0 or width % 8 != 0:
          raise ValueError(F"`height` and `width` have to be divisible by 8 but are {height} and {width}."       )

        if (callback_steps is None) or (
            callback_steps is not None and (not isinstance(__UpperCamelCase    ,			__UpperCamelCase       ) or callback_steps <= 0)
        ):
          raise ValueError(
              F"`callback_steps` has to be a positive integer but is {callback_steps} of type"
              F" {type(__UpperCamelCase       )}."       )

        # get prompt text embeddings
        lowerCAmelCase_   :				List[Any]								= self.tokenizer(
            __UpperCamelCase    ,			padding='max_length'    ,			max_length=self.tokenizer.model_max_length    ,			return_tensors='pt'    ,			)
        lowerCAmelCase_   :				List[Any]								= text_inputs.input_ids

        if text_input_ids.shape[-1] > self.tokenizer.model_max_length:
          lowerCAmelCase_   :				List[Any]								= self.tokenizer.batch_decode(text_input_ids[:, self.tokenizer.model_max_length :]       )
          logger.warning(
              'The following part of your input was truncated because CLIP can only handle sequences up to'
              F" {self.tokenizer.model_max_length} tokens: {removed_text}"       )
          lowerCAmelCase_   :				Any								= text_input_ids[:, : self.tokenizer.model_max_length]
        lowerCAmelCase_   :				List[str]								= self.text_encoder(text_input_ids.to(self.device       )       )[0]

        # duplicate text embeddings for each generation per prompt, using mps friendly method
        lowerCAmelCase_						,lowerCAmelCase_						,lowerCAmelCase_   :				Optional[Any]								= text_embeddings.shape
        lowerCAmelCase_   :				Dict								= text_embeddings.repeat(1    ,			__UpperCamelCase    ,			1       )
        lowerCAmelCase_   :				Union[str, Any]								= text_embeddings.view(bs_embed * num_images_per_prompt    ,			__UpperCamelCase    ,			-1       )

        # here `guidance_scale` is defined analog to the guidance weight `w` of equation (2)
        # of the Imagen paper: https://arxiv.org/pdf/2205.11487.pdf . `guidance_scale = 1`
        # corresponds to doing no classifier free guidance.
        lowerCAmelCase_   :				str								= guidance_scale > 1.0
        # get unconditional embeddings for classifier free guidance
        if do_classifier_free_guidance:
          lowerCAmelCase_   :				Optional[Any]								= 4_2
          if negative_prompt is None:
            lowerCAmelCase_   :				int								= [''] * batch_size
          elif type(__UpperCamelCase       ) is not type(__UpperCamelCase       ):
            raise TypeError(
                F"`negative_prompt` should be the same type to `prompt`, but got {type(__UpperCamelCase       )} !="
                F" {type(__UpperCamelCase       )}."       )
          elif isinstance(__UpperCamelCase    ,			__UpperCamelCase       ):
            lowerCAmelCase_   :				Union[str, Any]								= [negative_prompt]
          elif batch_size != len(__UpperCamelCase       ):
            raise ValueError(
                F"`negative_prompt`: {negative_prompt} has batch size {len(__UpperCamelCase       )}, but `prompt`:"
                F" {prompt} has batch size {batch_size}. Please make sure that passed `negative_prompt` matches"
                ' the batch size of `prompt`.'       )
          else:
            lowerCAmelCase_   :				str								= negative_prompt

          lowerCAmelCase_   :				Tuple								= text_input_ids.shape[-1]
          lowerCAmelCase_   :				Optional[int]								= self.tokenizer(
              __UpperCamelCase    ,			padding='max_length'    ,			max_length=__UpperCamelCase    ,			truncation=__UpperCamelCase    ,			return_tensors='pt'    ,			)
          lowerCAmelCase_   :				Optional[int]								= self.text_encoder(uncond_input.input_ids.to(self.device       )       )[0]

          # duplicate unconditional embeddings for each generation per prompt, using mps friendly method
          lowerCAmelCase_   :				int								= uncond_embeddings.shape[1]
          lowerCAmelCase_   :				Optional[Any]								= uncond_embeddings.repeat(1    ,			__UpperCamelCase    ,			1       )
          lowerCAmelCase_   :				Optional[int]								= uncond_embeddings.view(batch_size * num_images_per_prompt    ,			__UpperCamelCase    ,			-1       )

          # For classifier free guidance, we need to do two forward passes.
          # Here we concatenate the unconditional and text embeddings into a single batch
          # to avoid doing two forward passes
          lowerCAmelCase_   :				Optional[int]								= torch.cat([uncond_embeddings, text_embeddings]       )

        # get the initial random noise unless the user supplied it

        # Unlike in other pipelines, latents need to be generated in the target device
        # for 1-to-1 results reproducibility with the CompVis implementation.
        # However this currently doesn't work in `mps`.
        lowerCAmelCase_   :				List[Any]								= (batch_size * num_images_per_prompt, self.unet.config.in_channels, height // 8, width // 8)
        lowerCAmelCase_   :				Dict								= text_embeddings.dtype
        if latents is None:
          if self.device.type == "mps":
            # randn does not exist on mps
            lowerCAmelCase_   :				int								= torch.randn(__UpperCamelCase    ,			generator=__UpperCamelCase    ,			device='cpu'    ,			dtype=__UpperCamelCase       ).to(
                self.device       )
          else:
            lowerCAmelCase_   :				List[str]								= torch.randn(__UpperCamelCase    ,			generator=__UpperCamelCase    ,			device=self.device    ,			dtype=__UpperCamelCase       )
        else:
          if latents.shape != latents_shape:
            raise ValueError(F"Unexpected latents shape, got {latents.shape}, expected {latents_shape}"       )
          lowerCAmelCase_   :				str								= latents.to(self.device       )

        # set timesteps
        self.scheduler.set_timesteps(__UpperCamelCase       )

        # Some schedulers like PNDM have timesteps as arrays
        # It's more optimized to move all timesteps to correct device beforehand
        lowerCAmelCase_   :				List[str]								= self.scheduler.timesteps.to(self.device       )

        # scale the initial noise by the standard deviation required by the scheduler
        lowerCAmelCase_   :				Dict								= latents * self.scheduler.init_noise_sigma

        # prepare extra kwargs for the scheduler step, since not all schedulers have the same signature
        # eta (η) is only used with the DDIMScheduler, it will be ignored for other schedulers.
        # eta corresponds to η in DDIM paper: https://arxiv.org/abs/2010.02502
        # and should be between [0, 1]
        lowerCAmelCase_   :				int								= 'eta' in set(inspect.signature(self.scheduler.step       ).parameters.keys()       )
        lowerCAmelCase_   :				List[Any]								= {}
        if accepts_eta:
          lowerCAmelCase_   :				List[str]								= eta

        for i, t in enumerate(self.progress_bar(__UpperCamelCase       )       ):
          # expand the latents if we are doing classifier free guidance
          lowerCAmelCase_   :				Dict								= torch.cat([latents] * 2       ) if do_classifier_free_guidance else latents
          lowerCAmelCase_   :				Tuple								= self.scheduler.scale_model_input(__UpperCamelCase    ,			__UpperCamelCase       )

          # predict the noise residual
          lowerCAmelCase_   :				str								= self.unet(__UpperCamelCase    ,			__UpperCamelCase    ,			encoder_hidden_states=__UpperCamelCase       ).sample

          # perform guidance
          if do_classifier_free_guidance:
            lowerCAmelCase_						,lowerCAmelCase_   :				int								= noise_pred.chunk(2       )
            lowerCAmelCase_   :				Tuple								= noise_pred_uncond + guidance_scale * (noise_pred_text - noise_pred_uncond)

          # compute the previous noisy sample x_t -> x_t-1
          lowerCAmelCase_   :				int								= self.scheduler.step(__UpperCamelCase    ,			__UpperCamelCase    ,			__UpperCamelCase    ,			**__UpperCamelCase       ).prev_sample

          # call the callback, if provided
          if callback is not None and i % callback_steps == 0:
            callback(__UpperCamelCase    ,			__UpperCamelCase    ,			__UpperCamelCase       )

        lowerCAmelCase_   :				Tuple								= 1 / 0.1_82_15 * latents
        lowerCAmelCase_   :				Dict								= self.vae.decode(__UpperCamelCase       ).sample

        lowerCAmelCase_   :				int								= (image / 2 + 0.5).clamp(0    ,			1       )

        # we always cast to float32 as this does not cause significant overhead and is compatible with bfloat16
        lowerCAmelCase_   :				Any								= image.cpu().permute(0    ,			2    ,			3    ,			1       ).float().numpy()

        if output_type == "pil":
          lowerCAmelCase_   :				Optional[Any]								= self.numpy_to_pil(__UpperCamelCase       )

        if not return_dict:
          return image

        return StableDiffusionPipelineOutput(images=__UpperCamelCase    ,			nsfw_content_detected=__UpperCamelCase       )












"""simple docstring"""
import random
import unittest

import numpy as np

from diffusers import (
    DPMSolverMultistepScheduler,
    EulerAncestralDiscreteScheduler,
    EulerDiscreteScheduler,
    LMSDiscreteScheduler,
    OnnxStableDiffusionImgaImgPipeline,
    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 					_UpperCAmelCase   (	lowercase_     ,							unittest.TestCase ):
					UpperCamelCase      =							'''hf-internal-testing/tiny-random-OnnxStableDiffusionPipeline'''


					def 	lowerCamelCase       (					self			:Optional[int]     ,       __UpperCamelCase			:Union[str, Any]=0		):
												A		=  floats_tensor((1, 3, 1_28, 1_28)     ,       rng=random.Random(__UpperCamelCase		)		)
												A		=  np.random.RandomState(__UpperCamelCase		)
												A		=  {
												    "prompt": "A painting of a squirrel eating a burger",
												    "image": image,
												    "generator": generator,
												    "num_inference_steps": 3,
												    "strength": 0.75,
												    "guidance_scale": 7.5,
												    "output_type": "numpy",
												}
												return inputs


					def 	lowerCamelCase       (					self			:Any		):
												A		=  OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint     ,       provider="CPUExecutionProvider"		)
												pipe.set_progress_bar_config(disable=__UpperCamelCase		)

												A		=  self.get_dummy_inputs()
												A		=  pipe(**__UpperCamelCase		).images
												A		=  image[0, -3:, -3:, -1].flatten()

												assert image.shape == (1, 1_28, 1_28, 3)
												A		=  np.array([0.69_643, 0.58_484, 0.50_314, 0.58_760, 0.55_368, 0.59_643, 0.51_529, 0.41_217, 0.49_087]		)
												assert np.abs(image_slice - expected_slice		).max() < 1e-1


					def 	lowerCamelCase       (					self			:Dict		):
												A		=  OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint     ,       provider="CPUExecutionProvider"		)
												A		=  PNDMScheduler.from_config(pipe.scheduler.config     ,       skip_prk_steps=__UpperCamelCase		)
												pipe.set_progress_bar_config(disable=__UpperCamelCase		)

												A		=  self.get_dummy_inputs()
												A		=  pipe(**__UpperCamelCase		).images
												A		=  image[0, -3:, -3:, -1]

												assert image.shape == (1, 1_28, 1_28, 3)
												A		=  np.array([0.61_737, 0.54_642, 0.53_183, 0.54_465, 0.52_742, 0.60_525, 0.49_969, 0.40_655, 0.48_154]		)

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


					def 	lowerCamelCase       (					self			:Optional[Any]		):
												A		=  OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint     ,       provider="CPUExecutionProvider"		)
												A		=  LMSDiscreteScheduler.from_config(pipe.scheduler.config		)
												pipe.set_progress_bar_config(disable=__UpperCamelCase		)

												# warmup pass to apply optimizations
												A		=  pipe(**self.get_dummy_inputs()		)

												A		=  self.get_dummy_inputs()
												A		=  pipe(**__UpperCamelCase		).images
												A		=  image[0, -3:, -3:, -1]

												assert image.shape == (1, 1_28, 1_28, 3)
												A		=  np.array([0.52_761, 0.59_977, 0.49_033, 0.49_619, 0.54_282, 0.50_311, 0.47_600, 0.40_918, 0.45_203]		)

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


					def 	lowerCamelCase       (					self			:Dict		):
												A		=  OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint     ,       provider="CPUExecutionProvider"		)
												A		=  EulerDiscreteScheduler.from_config(pipe.scheduler.config		)
												pipe.set_progress_bar_config(disable=__UpperCamelCase		)

												A		=  self.get_dummy_inputs()
												A		=  pipe(**__UpperCamelCase		).images
												A		=  image[0, -3:, -3:, -1]

												assert image.shape == (1, 1_28, 1_28, 3)
												A		=  np.array([0.52_911, 0.60_004, 0.49_229, 0.49_805, 0.54_502, 0.50_680, 0.47_777, 0.41_028, 0.45_304]		)

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


					def 	lowerCamelCase       (					self			:Optional[Any]		):
												A		=  OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint     ,       provider="CPUExecutionProvider"		)
												A		=  EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config		)
												pipe.set_progress_bar_config(disable=__UpperCamelCase		)

												A		=  self.get_dummy_inputs()
												A		=  pipe(**__UpperCamelCase		).images
												A		=  image[0, -3:, -3:, -1]

												assert image.shape == (1, 1_28, 1_28, 3)
												A		=  np.array([0.52_911, 0.60_004, 0.49_229, 0.49_805, 0.54_502, 0.50_680, 0.47_777, 0.41_028, 0.45_304]		)

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


					def 	lowerCamelCase       (					self			:Union[str, Any]		):
												A		=  OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint     ,       provider="CPUExecutionProvider"		)
												A		=  DPMSolverMultistepScheduler.from_config(pipe.scheduler.config		)
												pipe.set_progress_bar_config(disable=__UpperCamelCase		)

												A		=  self.get_dummy_inputs()
												A		=  pipe(**__UpperCamelCase		).images
												A		=  image[0, -3:, -3:, -1]

												assert image.shape == (1, 1_28, 1_28, 3)
												A		=  np.array([0.65_331, 0.58_277, 0.48_204, 0.56_059, 0.53_665, 0.56_235, 0.50_969, 0.40_009, 0.46_552]		)

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







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


					@property
					def 	lowerCamelCase       (					self			:Optional[Any]		):
												return (
												    "CUDAExecutionProvider",
												    {
												        "gpu_mem_limit": "15000000000",  # 15GB
												        "arena_extend_strategy": "kSameAsRequested",
												    },
												)


					@property
					def 	lowerCamelCase       (					self			:Optional[int]		):
												A		=  ort.SessionOptions()
												A		=  False
												return options


					def 	lowerCamelCase       (					self			:Dict		):
												A		=  load_image(
												    "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
												    "/img2img/sketch-mountains-input.jpg"		)
												A		=  init_image.resize((7_68, 5_12)		)
												# using the PNDM scheduler by default
												A		=  OnnxStableDiffusionImgaImgPipeline.from_pretrained(
												    "CompVis/stable-diffusion-v1-4"     ,       revision="onnx"     ,       safety_checker=__UpperCamelCase     ,       feature_extractor=__UpperCamelCase     ,       provider=self.gpu_provider     ,       sess_options=self.gpu_options     ,       )
												pipe.set_progress_bar_config(disable=__UpperCamelCase		)

												A		=  "A fantasy landscape, trending on artstation"

												A		=  np.random.RandomState(0		)
												A		=  pipe(
												    prompt=__UpperCamelCase     ,       image=__UpperCamelCase     ,       strength=0.75     ,       guidance_scale=7.5     ,       num_inference_steps=10     ,       generator=__UpperCamelCase     ,       output_type="np"     ,       )
												A		=  output.images
												A		=  images[0, 2_55:2_58, 3_83:3_86, -1]

												assert images.shape == (1, 5_12, 7_68, 3)
												A		=  np.array([0.4_909, 0.5_059, 0.5_372, 0.4_623, 0.4_876, 0.5_049, 0.4_820, 0.4_956, 0.5_019]		)
												# TODO: lower the tolerance after finding the cause of onnxruntime reproducibility issues

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


					def 	lowerCamelCase       (					self			:Any		):
												A		=  load_image(
												    "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
												    "/img2img/sketch-mountains-input.jpg"		)
												A		=  init_image.resize((7_68, 5_12)		)
												A		=  LMSDiscreteScheduler.from_pretrained(
												    "runwayml/stable-diffusion-v1-5"     ,       subfolder="scheduler"     ,       revision="onnx"		)
												A		=  OnnxStableDiffusionImgaImgPipeline.from_pretrained(
												    "runwayml/stable-diffusion-v1-5"     ,       revision="onnx"     ,       scheduler=__UpperCamelCase     ,       safety_checker=__UpperCamelCase     ,       feature_extractor=__UpperCamelCase     ,       provider=self.gpu_provider     ,       sess_options=self.gpu_options     ,       )
												pipe.set_progress_bar_config(disable=__UpperCamelCase		)

												A		=  "A fantasy landscape, trending on artstation"

												A		=  np.random.RandomState(0		)
												A		=  pipe(
												    prompt=__UpperCamelCase     ,       image=__UpperCamelCase     ,       strength=0.75     ,       guidance_scale=7.5     ,       num_inference_steps=20     ,       generator=__UpperCamelCase     ,       output_type="np"     ,       )
												A		=  output.images
												A		=  images[0, 2_55:2_58, 3_83:3_86, -1]

												assert images.shape == (1, 5_12, 7_68, 3)
												A		=  np.array([0.8_043, 0.926, 0.9_581, 0.8_119, 0.8_954, 0.913, 0.7_209, 0.7_463, 0.7_431]		)
												# TODO: lower the tolerance after finding the cause of onnxruntime reproducibility issues

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


