
"""simple docstring"""


import re
import string
from collections import Counter

import sacrebleu
import sacremoses
from packaging import version

import datasets


_lowercase							   =				'''
@inproceedings{xu-etal-2016-optimizing,
    title = {Optimizing Statistical Machine Translation for Text Simplification},
    authors={Xu, Wei and Napoles, Courtney and Pavlick, Ellie and Chen, Quanze and Callison-Burch, Chris},
    journal = {Transactions of the Association for Computational Linguistics},
    volume = {4},
    year={2016},
    url = {https://www.aclweb.org/anthology/Q16-1029},
    pages = {401--415
},
@inproceedings{post-2018-call,
    title = "A Call for Clarity in Reporting {BLEU} Scores",
    author = "Post, Matt",
    booktitle = "Proceedings of the Third Conference on Machine Translation: Research Papers",
    month = oct,
    year = "2018",
    address = "Belgium, Brussels",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W18-6319",
    pages = "186--191",
}
'''

_lowercase							   =				'''\
WIKI_SPLIT is the combination of three metrics SARI, EXACT and SACREBLEU
It can be used to evaluate the quality of machine-generated texts.
'''


_lowercase							   =				'''
Calculates sari score (between 0 and 100) given a list of source and predicted
sentences, and a list of lists of reference sentences. It also computes the BLEU score as well as the exact match score.
Args:
    sources: list of source sentences where each sentence should be a string.
    predictions: list of predicted sentences where each sentence should be a string.
    references: list of lists of reference sentences where each sentence should be a string.
Returns:
    sari: sari score
    sacrebleu: sacrebleu score
    exact: exact score

Examples:
    >>> sources=["About 95 species are currently accepted ."]
    >>> predictions=["About 95 you now get in ."]
    >>> references=[["About 95 species are currently known ."]]
    >>> wiki_split = datasets.load_metric("wiki_split")
    >>> results = wiki_split.compute(sources=sources, predictions=predictions, references=references)
    >>> print(results)
    {\'sari\': 21.805555555555557, \'sacrebleu\': 14.535768424205482, \'exact\': 0.0}
'''






def       _snake_case				(		snake_case__   :     List[str]     ):

	def remove_articles(snake_case__   :     List[Any]     ):
		A						   =   re.compile(r'\b(a|an|the)\b'	,      re.UNICODE     )
		return re.sub(snake_case__	,      ' '	,      snake_case__     )

	def white_space_fix(snake_case__   :     Tuple     ):
		return " ".join(text.split()     )

	def remove_punc(snake_case__   :     int     ):
		A						   =   set(string.punctuation     )
		return "".join(ch for ch in text if ch not in exclude     )

	def lower(snake_case__   :     Union[str, Any]     ):
		return text.lower()

	return white_space_fix(remove_articles(remove_punc(lower(snake_case__     )     )     )     )






def       _snake_case				(		snake_case__   :     str	,      snake_case__   :     List[Any]     ):
	return int(normalize_answer(snake_case__     ) == normalize_answer(snake_case__     )     )






def       _snake_case				(		snake_case__   :     int	,      snake_case__   :     Union[str, Any]     ):
	A						   =   [any(compute_exact(snake_case__	,      snake_case__     ) for ref in refs     ) for pred, refs in zip(snake_case__	,      snake_case__     )]
	return (sum(snake_case__     ) / len(snake_case__     )) * 100






def       _snake_case				(		snake_case__   :     Tuple	,      snake_case__   :     List[str]	,      snake_case__   :     Tuple	,      snake_case__   :     Optional[Any]     ):
	A						   =   [rgram for rgrams in rgramslist for rgram in rgrams]
	A						   =   Counter(snake_case__     )

	A						   =   Counter(snake_case__     )
	A						   =   Counter()
	for sgram, scount in sgramcounter.items():
		A						   =   scount * numref

	A						   =   Counter(snake_case__     )
	A						   =   Counter()
	for cgram, ccount in cgramcounter.items():
		A						   =   ccount * numref

	# KEEP
	A						   =   sgramcounter_rep & cgramcounter_rep
	A						   =   keepgramcounter_rep & rgramcounter
	A						   =   sgramcounter_rep & rgramcounter

	A						   =   0
	A						   =   0
	for keepgram in keepgramcountergood_rep:
		keeptmpscorea += keepgramcountergood_rep[keepgram] / keepgramcounter_rep[keepgram]
		# Fix an alleged bug [2] in the keep score computation.
		# keeptmpscore2 += keepgramcountergood_rep[keepgram] / keepgramcounterall_rep[keepgram]
		keeptmpscorea += keepgramcountergood_rep[keepgram]
	# Define 0/0=1 instead of 0 to give higher scores for predictions that match
	#      a target exactly.
	A						   =   1
	A						   =   1
	if len(snake_case__     ) > 0:
		A						   =   keeptmpscorea / len(snake_case__     )
	if len(snake_case__     ) > 0:
		# Fix an alleged bug [2] in the keep score computation.
		# keepscore_recall = keeptmpscore2 / len(keepgramcounterall_rep)
		A						   =   keeptmpscorea / sum(keepgramcounterall_rep.values()     )
	A						   =   0
	if keepscore_precision > 0 or keepscore_recall > 0:
		A						   =   2 * keepscore_precision * keepscore_recall / (keepscore_precision + keepscore_recall)

	# DELETION
	A						   =   sgramcounter_rep - cgramcounter_rep
	A						   =   delgramcounter_rep - rgramcounter
	A						   =   sgramcounter_rep - rgramcounter
	A						   =   0
	A						   =   0
	for delgram in delgramcountergood_rep:
		deltmpscorea += delgramcountergood_rep[delgram] / delgramcounter_rep[delgram]
		deltmpscorea += delgramcountergood_rep[delgram] / delgramcounterall_rep[delgram]
	# Define 0/0=1 instead of 0 to give higher scores for predictions that match
	# a target exactly.
	A						   =   1
	if len(snake_case__     ) > 0:
		A						   =   deltmpscorea / len(snake_case__     )

	# ADDITION
	A						   =   set(snake_case__     ) - set(snake_case__     )
	A						   =   set(snake_case__     ) & set(snake_case__     )
	A						   =   set(snake_case__     ) - set(snake_case__     )

	A						   =   0
	for addgram in addgramcountergood:
		addtmpscore += 1

	# Define 0/0=1 instead of 0 to give higher scores for predictions that match
	# a target exactly.
	A						   =   1
	A						   =   1
	if len(snake_case__     ) > 0:
		A						   =   addtmpscore / len(snake_case__     )
	if len(snake_case__     ) > 0:
		A						   =   addtmpscore / len(snake_case__     )
	A						   =   0
	if addscore_precision > 0 or addscore_recall > 0:
		A						   =   2 * addscore_precision * addscore_recall / (addscore_precision + addscore_recall)

	return (keepscore, delscore_precision, addscore)






def       _snake_case				(		snake_case__   :     Optional[Any]	,      snake_case__   :     Any	,      snake_case__   :     str     ):
	A						   =   len(snake_case__     )

	A						   =   ssent.split(' '     )
	A						   =   csent.split(' '     )
	A						   =   []
	A						   =   []
	A						   =   []
	A						   =   []
	A						   =   []
	A						   =   []

	A						   =   []
	A						   =   []
	A						   =   []
	A						   =   []
	for rsent in rsents:
		A						   =   rsent.split(' '     )
		A						   =   []
		A						   =   []
		A						   =   []
		ragramslist.append(snake_case__     )
		for i in range(0	,      len(snake_case__     ) - 1     ):
			if i < len(snake_case__     ) - 1:
				A						   =   ragrams[i] + ' ' + ragrams[i + 1]
				ragrams.append(snake_case__     )
			if i < len(snake_case__     ) - 2:
				A						   =   ragrams[i] + ' ' + ragrams[i + 1] + ' ' + ragrams[i + 2]
				ragrams.append(snake_case__     )
			if i < len(snake_case__     ) - 3:
				A						   =   ragrams[i] + ' ' + ragrams[i + 1] + ' ' + ragrams[i + 2] + ' ' + ragrams[i + 3]
				ragrams.append(snake_case__     )
		ragramslist.append(snake_case__     )
		ragramslist.append(snake_case__     )
		ragramslist.append(snake_case__     )

	for i in range(0	,      len(snake_case__     ) - 1     ):
		if i < len(snake_case__     ) - 1:
			A						   =   sagrams[i] + ' ' + sagrams[i + 1]
			sagrams.append(snake_case__     )
		if i < len(snake_case__     ) - 2:
			A						   =   sagrams[i] + ' ' + sagrams[i + 1] + ' ' + sagrams[i + 2]
			sagrams.append(snake_case__     )
		if i < len(snake_case__     ) - 3:
			A						   =   sagrams[i] + ' ' + sagrams[i + 1] + ' ' + sagrams[i + 2] + ' ' + sagrams[i + 3]
			sagrams.append(snake_case__     )

	for i in range(0	,      len(snake_case__     ) - 1     ):
		if i < len(snake_case__     ) - 1:
			A						   =   cagrams[i] + ' ' + cagrams[i + 1]
			cagrams.append(snake_case__     )
		if i < len(snake_case__     ) - 2:
			A						   =   cagrams[i] + ' ' + cagrams[i + 1] + ' ' + cagrams[i + 2]
			cagrams.append(snake_case__     )
		if i < len(snake_case__     ) - 3:
			A						   =   cagrams[i] + ' ' + cagrams[i + 1] + ' ' + cagrams[i + 2] + ' ' + cagrams[i + 3]
			cagrams.append(snake_case__     )

	((A)   ,      (A)   ,      (A))						   =   SARIngram(snake_case__	,      snake_case__	,      snake_case__	,      snake_case__     )
	((A)   ,      (A)   ,      (A))						   =   SARIngram(snake_case__	,      snake_case__	,      snake_case__	,      snake_case__     )
	((A)   ,      (A)   ,      (A))						   =   SARIngram(snake_case__	,      snake_case__	,      snake_case__	,      snake_case__     )
	((A)   ,      (A)   ,      (A))						   =   SARIngram(snake_case__	,      snake_case__	,      snake_case__	,      snake_case__     )
	A						   =   sum([keepascore, keepascore, keepascore, keepascore]     ) / 4
	A						   =   sum([delascore, delascore, delascore, delascore]     ) / 4
	A						   =   sum([addascore, addascore, addascore, addascore]     ) / 4
	A						   =   (avgkeepscore + avgdelscore + avgaddscore) / 3
	return finalscore






def       _snake_case				(		snake_case__   :     Dict	,      snake_case__   :     bool = True	,      snake_case__   :     str = "13a"	,      snake_case__   :     bool = True     ):
	# Normalization is requried for the ASSET dataset (one of the primary
	# datasets in sentence simplification) to allow using space
	# to split the sentence. Even though Wiki-Auto and TURK datasets,
	# do not require normalization, we do it for consistency.
	# Code adapted from the EASSE library [1] written by the authors of the ASSET dataset.
	# [1] https://github.com/feralvam/easse/blob/580bba7e1378fc8289c663f864e0487188fe8067/easse/utils/preprocessing.py#L7

	if lowercase:
		A						   =   sentence.lower()

	if tokenizer in ["13a", "intl"]:
		if version.parse(sacrebleu.__version__     ).major >= 2:
			A						   =   sacrebleu.metrics.bleu._get_tokenizer(snake_case__     )()(snake_case__     )
		else:
			A						   =   sacrebleu.TOKENIZERS[tokenizer]()(snake_case__     )
	elif tokenizer == "moses":
		A						   =   sacremoses.MosesTokenizer().tokenize(snake_case__	,      return_str=snake_case__	,      escape=snake_case__     )
	elif tokenizer == "penn":
		A						   =   sacremoses.MosesTokenizer().penn_tokenize(snake_case__	,      return_str=snake_case__     )
	else:
		A						   =   sentence

	if not return_str:
		A						   =   normalized_sent.split()

	return normalized_sent






def       _snake_case				(		snake_case__   :     List[str]	,      snake_case__   :     Union[str, Any]	,      snake_case__   :     Dict     ):
	if not (len(snake_case__     ) == len(snake_case__     ) == len(snake_case__     )):
		raise ValueError('Sources length must match predictions and references lengths.'     )
	A						   =   0
	for src, pred, refs in zip(snake_case__	,      snake_case__	,      snake_case__     ):
		sari_score += SARIsent(normalize(snake_case__     )	,      normalize(snake_case__     )	,      [normalize(snake_case__     ) for sent in refs]     )
	A						   =   sari_score / len(snake_case__     )
	return 100 * sari_score






def       _snake_case				(		snake_case__   :     Optional[int]	,      snake_case__   :     str	,      snake_case__   :     Union[str, Any]="exp"	,      snake_case__   :     Dict=None	,      snake_case__   :     Union[str, Any]=False	,      snake_case__   :     Dict=False	,      snake_case__   :     Optional[Any]=False	,      ):
	A						   =   len(references[0]     )
	if any(len(snake_case__     ) != references_per_prediction for refs in references     ):
		raise ValueError('Sacrebleu requires the same number of references for each prediction'     )
	A						   =   [[refs[i] for refs in references] for i in range(snake_case__     )]
	A						   =   sacrebleu.corpus_bleu(
	    snake_case__	,      snake_case__	,      smooth_method=snake_case__	,      smooth_value=snake_case__	,      force=snake_case__	,      lowercase=snake_case__	,      use_effective_order=snake_case__	,      )
	return output.score







@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION		,					_KWARGS_DESCRIPTION    )
class 				lowerCAmelCase_				(      datasets.Metric    ):



						'''simple docstring'''


						def 						_SCREAMING_SNAKE_CASE      ( self     :      Dict      )     ->   Optional[Any]:
							return datasets.MetricInfo(
							    description=_DESCRIPTION  ,citation=_CITATION  ,inputs_description=_KWARGS_DESCRIPTION  ,features=datasets.Features(
							        {
							            'predictions': datasets.Value('string'  ,id='sequence'      ),
							            'references': datasets.Sequence(datasets.Value('string'  ,id='sequence'      )  ,id='references'      ),
							        }      )  ,codebase_urls=[
							        'https://github.com/huggingface/transformers/blob/master/src/transformers/data/metrics/squad_metrics.py',
							        'https://github.com/cocoxu/simplification/blob/master/SARI.py',
							        'https://github.com/tensorflow/tensor2tensor/blob/master/tensor2tensor/utils/sari_hook.py',
							        'https://github.com/mjpost/sacreBLEU',
							    ]  ,reference_urls=[
							        'https://www.aclweb.org/anthology/Q16-1029.pdf',
							        'https://github.com/mjpost/sacreBLEU',
							        'https://en.wikipedia.org/wiki/BLEU',
							        'https://towardsdatascience.com/evaluating-text-output-in-nlp-bleu-at-your-own-risk-e8609665a213',
							    ]  ,)




						def 						_SCREAMING_SNAKE_CASE      ( self     :      Union[str, Any]  ,A_     :      Optional[Any]  ,A_     :      int  ,A_     :      Any      )     ->   Union[str, Any]:
							A						   =   {}
							result.update({'sari': compute_sari(sources=A_  ,predictions=A_  ,references=A_      )}      )
							result.update({'sacrebleu': compute_sacrebleu(predictions=A_  ,references=A_      )}      )
							result.update({'exact': compute_em(predictions=A_  ,references=A_      )}      )
							return result

"""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 				lowerCAmelCase_				(      _lowercase		,					unittest.TestCase    ):



						'''simple docstring'''


						_lowerCamelCase:    Tuple      =    '''hf-internal-testing/tiny-random-OnnxStableDiffusionPipeline'''


						def 						_SCREAMING_SNAKE_CASE      ( self     :      List[Any]  ,A_     :      List[str]=0      )     ->   Dict:
							A						   =   floats_tensor((1, 3, 128, 128)  ,rng=random.Random(A_      )      )
							A						   =   np.random.RandomState(A_      )
							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 						_SCREAMING_SNAKE_CASE      ( self     :      str      )     ->   Optional[int]:
							A						   =   OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint  ,provider='CPUExecutionProvider'      )
							pipe.set_progress_bar_config(disable=A_      )

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

							assert image.shape == (1, 128, 128, 3)
							A						   =   np.array([0.6_96_43, 0.5_84_84, 0.5_03_14, 0.5_87_60, 0.5_53_68, 0.5_96_43, 0.5_15_29, 0.4_12_17, 0.4_90_87]      )
							assert np.abs(image_slice - expected_slice      ).max() < 1e-1


						def 						_SCREAMING_SNAKE_CASE      ( self     :      str      )     ->   Union[str, Any]:
							A						   =   OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint  ,provider='CPUExecutionProvider'      )
							A						   =   PNDMScheduler.from_config(pipe.scheduler.config  ,skip_prk_steps=A_      )
							pipe.set_progress_bar_config(disable=A_      )

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

							assert image.shape == (1, 128, 128, 3)
							A						   =   np.array([0.6_17_37, 0.5_46_42, 0.5_31_83, 0.5_44_65, 0.5_27_42, 0.6_05_25, 0.4_99_69, 0.4_06_55, 0.4_81_54]      )

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


						def 						_SCREAMING_SNAKE_CASE      ( self     :      Optional[Any]      )     ->   Dict:
							A						   =   OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint  ,provider='CPUExecutionProvider'      )
							A						   =   LMSDiscreteScheduler.from_config(pipe.scheduler.config      )
							pipe.set_progress_bar_config(disable=A_      )

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

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

							assert image.shape == (1, 128, 128, 3)
							A						   =   np.array([0.5_27_61, 0.5_99_77, 0.4_90_33, 0.4_96_19, 0.5_42_82, 0.5_03_11, 0.4_76_00, 0.4_09_18, 0.4_52_03]      )

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


						def 						_SCREAMING_SNAKE_CASE      ( self     :      int      )     ->   Optional[int]:
							A						   =   OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint  ,provider='CPUExecutionProvider'      )
							A						   =   EulerDiscreteScheduler.from_config(pipe.scheduler.config      )
							pipe.set_progress_bar_config(disable=A_      )

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

							assert image.shape == (1, 128, 128, 3)
							A						   =   np.array([0.5_29_11, 0.6_00_04, 0.4_92_29, 0.4_98_05, 0.5_45_02, 0.5_06_80, 0.4_77_77, 0.4_10_28, 0.4_53_04]      )

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


						def 						_SCREAMING_SNAKE_CASE      ( self     :      List[str]      )     ->   Optional[int]:
							A						   =   OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint  ,provider='CPUExecutionProvider'      )
							A						   =   EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config      )
							pipe.set_progress_bar_config(disable=A_      )

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

							assert image.shape == (1, 128, 128, 3)
							A						   =   np.array([0.5_29_11, 0.6_00_04, 0.4_92_29, 0.4_98_05, 0.5_45_02, 0.5_06_80, 0.4_77_77, 0.4_10_28, 0.4_53_04]      )

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




						def 						_SCREAMING_SNAKE_CASE      ( self     :      str      )     ->   Optional[Any]:
							A						   =   OnnxStableDiffusionImgaImgPipeline.from_pretrained(self.hub_checkpoint  ,provider='CPUExecutionProvider'      )
							A						   =   DPMSolverMultistepScheduler.from_config(pipe.scheduler.config      )
							pipe.set_progress_bar_config(disable=A_      )

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

							assert image.shape == (1, 128, 128, 3)
							A						   =   np.array([0.6_53_31, 0.5_82_77, 0.4_82_04, 0.5_60_59, 0.5_36_65, 0.5_62_35, 0.5_09_69, 0.4_00_09, 0.4_65_52]      )

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







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



						'''simple docstring'''


						@property
						def 						_SCREAMING_SNAKE_CASE      ( self     :      Any      )     ->   Union[str, Any]:
							return (
							    "CUDAExecutionProvider",
							    {
							        "gpu_mem_limit": "15000000000",  # 15GB
							        "arena_extend_strategy": "kSameAsRequested",
							    },
							)


						@property
						def 						_SCREAMING_SNAKE_CASE      ( self     :      Dict      )     ->   str:
							A						   =   ort.SessionOptions()
							A						   =   False
							return options


						def 						_SCREAMING_SNAKE_CASE      ( self     :      str      )     ->   Tuple:
							A						   =   load_image(
							    'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
							    '/img2img/sketch-mountains-input.jpg'      )
							A						   =   init_image.resize((768, 512)      )
							# using the PNDM scheduler by default
							A						   =   OnnxStableDiffusionImgaImgPipeline.from_pretrained(
							    'CompVis/stable-diffusion-v1-4'  ,revision='onnx'  ,safety_checker=A_  ,feature_extractor=A_  ,provider=self.gpu_provider  ,sess_options=self.gpu_options  ,)
							pipe.set_progress_bar_config(disable=A_      )

							A						   =   'A fantasy landscape, trending on artstation'

							A						   =   np.random.RandomState(0      )
							A						   =   pipe(
							    prompt=A_  ,image=A_  ,strength=0.75  ,guidance_scale=7.5  ,num_inference_steps=10  ,generator=A_  ,output_type='np'  ,)
							A						   =   output.images
							A						   =   images[0, 255:258, 383:386, -1]

							assert images.shape == (1, 512, 768, 3)
							A						   =   np.array([0.49_09, 0.50_59, 0.53_72, 0.46_23, 0.48_76, 0.50_49, 0.48_20, 0.49_56, 0.50_19]      )
							# TODO: lower the tolerance after finding the cause of onnxruntime reproducibility issues

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




						def 						_SCREAMING_SNAKE_CASE      ( self     :      Optional[Any]      )     ->   Any:
							A						   =   load_image(
							    'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
							    '/img2img/sketch-mountains-input.jpg'      )
							A						   =   init_image.resize((768, 512)      )
							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=A_  ,safety_checker=A_  ,feature_extractor=A_  ,provider=self.gpu_provider  ,sess_options=self.gpu_options  ,)
							pipe.set_progress_bar_config(disable=A_      )

							A						   =   'A fantasy landscape, trending on artstation'

							A						   =   np.random.RandomState(0      )
							A						   =   pipe(
							    prompt=A_  ,image=A_  ,strength=0.75  ,guidance_scale=7.5  ,num_inference_steps=20  ,generator=A_  ,output_type='np'  ,)
							A						   =   output.images
							A						   =   images[0, 255:258, 383:386, -1]

							assert images.shape == (1, 512, 768, 3)
							A						   =   np.array([0.80_43, 0.9_26, 0.95_81, 0.81_19, 0.89_54, 0.9_13, 0.72_09, 0.74_63, 0.74_31]      )
							# TODO: lower the tolerance after finding the cause of onnxruntime reproducibility issues

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