code: 
  
  
  
  
  """simple docstring"""
  
  from typing import Mapping
  
  from ...configuration_utils import PretrainedConfig
  from ...onnx import OnnxSeqaSeqConfigWithPast
  from ...utils import logging
  
  
  __A 		=			logging.get_logger(__name__)
  class 			lowerCamelCase__    (  lowerCamelCase_			):
  			a__ :      Any								=     """mt5"""
  			a__ :      Optional[int]								=     ["""past_key_values"""]
  
  
  			def __init__(     self				, SCREAMING_SNAKE_CASE=250_112				, SCREAMING_SNAKE_CASE=512				, SCREAMING_SNAKE_CASE=64				, SCREAMING_SNAKE_CASE=1_024				, SCREAMING_SNAKE_CASE=8				, SCREAMING_SNAKE_CASE=None				, SCREAMING_SNAKE_CASE=6				, SCREAMING_SNAKE_CASE=32				, SCREAMING_SNAKE_CASE=128				, SCREAMING_SNAKE_CASE=0.1				, SCREAMING_SNAKE_CASE=1E-6				, SCREAMING_SNAKE_CASE=1.0				, SCREAMING_SNAKE_CASE="gated-gelu"				, SCREAMING_SNAKE_CASE=True				, SCREAMING_SNAKE_CASE=True				, SCREAMING_SNAKE_CASE="T5Tokenizer"				, SCREAMING_SNAKE_CASE=False				, SCREAMING_SNAKE_CASE=0				, SCREAMING_SNAKE_CASE=1				, SCREAMING_SNAKE_CASE=0				, **SCREAMING_SNAKE_CASE				, ):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					super().__init__(
  					    is_encoder_decoder=SCREAMING_SNAKE_CASE				, tokenizer_class=SCREAMING_SNAKE_CASE				, tie_word_embeddings=SCREAMING_SNAKE_CASE				, pad_token_id=SCREAMING_SNAKE_CASE				, eos_token_id=SCREAMING_SNAKE_CASE				, decoder_start_token_id=SCREAMING_SNAKE_CASE				, **SCREAMING_SNAKE_CASE				, )
  					snake_case		:						int								=				vocab_size
  					snake_case		:						Tuple								=				d_model
  					snake_case		:						Any								=				d_kv
  					snake_case		:						Union[str, Any]								=				d_ff
  					snake_case		:						Optional[int]								=				num_layers
  					snake_case		:						Dict								=				(
  					    num_decoder_layers if num_decoder_layers is not None else self.num_layers
  					)  # default = symmetry
  					snake_case		:						Optional[Any]								=				num_heads
  					snake_case		:						Any								=				relative_attention_num_buckets
  					snake_case		:						List[str]								=				relative_attention_max_distance
  					snake_case		:						List[str]								=				dropout_rate
  					snake_case		:						List[Any]								=				layer_norm_epsilon
  					snake_case		:						Union[str, Any]								=				initializer_factor
  					snake_case		:						Dict								=				feed_forward_proj
  					snake_case		:						Tuple								=				use_cache
  
  					snake_case		:						Union[str, Any]								=				self.feed_forward_proj.split("-"							)
  					snake_case		:						Optional[Any]								=				act_info[-1]
  					snake_case		:						Optional[Any]								=				act_info[0] == "gated"
  
  					if len(SCREAMING_SNAKE_CASE							) > 1 and act_info[0] != "gated" or len(SCREAMING_SNAKE_CASE							) > 2:
  							raise ValueError(
  							    F'''`feed_forward_proj`: {feed_forward_proj} is not a valid activation function of the dense layer.'''
  							    "Please make sure `feed_forward_proj` is of the format `gated-{ACT_FN}` or `{ACT_FN}`, e.g. "
  							    "'gated-gelu' or 'relu'"							)
  
  					# for backwards compatibility
  					if feed_forward_proj == "gated-gelu":
  							snake_case		:						Tuple								=				"gelu_new"
  
  
  			@property
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					return self.d_model
  
  
  			@property
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					return self.num_heads
  
  
  
  			@property
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					return self.num_layers
  
  
  
  
  
  
  
  class 			lowerCamelCase__    (  lowerCamelCase_			):
  
  
  			@property
  			# Copied from transformers.models.t5.configuration_t5.T5OnnxConfig.inputs
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					snake_case		:						List[str]								=				{
  					    "input_ids": {0: "batch", 1: "encoder_sequence"},
  					    "attention_mask": {0: "batch", 1: "encoder_sequence"},
  					}
  					if self.use_past:
  							snake_case		:						List[Any]								=				"past_encoder_sequence + sequence"
  							snake_case		:						Tuple								=				{0: "batch"}
  							snake_case		:						Any								=				{0: "batch", 1: "past_decoder_sequence + sequence"}
  					else:
  							snake_case		:						List[Any]								=				{0: "batch", 1: "decoder_sequence"}
  							snake_case		:						Union[str, Any]								=				{0: "batch", 1: "decoder_sequence"}
  
  					if self.use_past:
  							self.fill_with_past_key_values_(SCREAMING_SNAKE_CASE				, direction="inputs"							)
  
  					return common_inputs
  
  
  			@property
  			# Copied from transformers.models.t5.configuration_t5.T5OnnxConfig.default_onnx_opset
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					return 13
  
  
  
  			@property
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					return 5E-4
  
  
style_context: 
  
  
  
  
  """simple docstring"""
  
  import gc
  import unittest
  
  import numpy as np
  import torch
  
  from diffusers import RePaintPipeline, RePaintScheduler, UNetaDModel
  from diffusers.utils.testing_utils import (
      enable_full_determinism,
      load_image,
      load_numpy,
      nightly,
      require_torch_gpu,
      skip_mps,
      torch_device,
  )
  
  from ..pipeline_params import IMAGE_INPAINTING_BATCH_PARAMS, IMAGE_INPAINTING_PARAMS
  from ..test_pipelines_common import PipelineTesterMixin
  
  
  enable_full_determinism()
  class 			lowerCamelCase__    (  lowerCamelCase_				,  unittest.TestCase			):
  			a__ :      Optional[Any]								=     RePaintPipeline
  			a__ :      List[Any]								=     IMAGE_INPAINTING_PARAMS - {"""width""", """height""", """guidance_scale"""}
  			a__ :      List[Any]								=     PipelineTesterMixin.required_optional_params - {
  			    """latents""",
  			    """num_images_per_prompt""",
  			    """callback""",
  			    """callback_steps""",
  			}
  			a__ :      List[Any]								=     IMAGE_INPAINTING_BATCH_PARAMS
  			a__ :      List[str]								=     False
  
  
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					torch.manual_seed(0							)
  					torch.manual_seed(0							)
  					snake_case		:						Union[str, Any]								=				UNetaDModel(
  					    block_out_channels=(32, 64)				, layers_per_block=2				, sample_size=32				, in_channels=3				, out_channels=3				, down_block_types=("DownBlock2D", "AttnDownBlock2D")				, up_block_types=("AttnUpBlock2D", "UpBlock2D")				, )
  					snake_case		:						Union[str, Any]								=				RePaintScheduler()
  					snake_case		:						Optional[Any]								=				{"unet": unet, "scheduler": scheduler}
  					return components
  
  
  			def 							lowerCamelCase_				(     self				, SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE=0							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					if str(SCREAMING_SNAKE_CASE							).startswith("mps"							):
  							snake_case		:						str								=				torch.manual_seed(SCREAMING_SNAKE_CASE							)
  					else:
  							snake_case		:						List[Any]								=				torch.Generator(device=SCREAMING_SNAKE_CASE							).manual_seed(SCREAMING_SNAKE_CASE							)
  					snake_case		:						Any								=				np.random.RandomState(SCREAMING_SNAKE_CASE							).standard_normal((1, 3, 32, 32)							)
  					snake_case		:						Any								=				torch.from_numpy(SCREAMING_SNAKE_CASE							).to(device=SCREAMING_SNAKE_CASE				, dtype=torch.floataa							)
  					snake_case		:						List[str]								=				(image > 0).to(device=SCREAMING_SNAKE_CASE				, dtype=torch.floataa							)
  					snake_case		:						int								=				{
  					    "image": image,
  					    "mask_image": mask,
  					    "generator": generator,
  					    "num_inference_steps": 5,
  					    "eta": 0.0,
  					    "jump_length": 2,
  					    "jump_n_sample": 2,
  					    "output_type": "numpy",
  					}
  					return inputs
  
  
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					snake_case		:						List[Any]								=				"cpu"  # ensure determinism for the device-dependent torch.Generator
  					snake_case		:						Any								=				self.get_dummy_components()
  					snake_case		:						Optional[int]								=				RePaintPipeline(**SCREAMING_SNAKE_CASE							)
  					snake_case		:						Optional[Any]								=				sd_pipe.to(SCREAMING_SNAKE_CASE							)
  					sd_pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE							)
  
  					snake_case		:						Any								=				self.get_dummy_inputs(SCREAMING_SNAKE_CASE							)
  					snake_case		:						Dict								=				sd_pipe(**SCREAMING_SNAKE_CASE							).images
  					snake_case		:						Optional[int]								=				image[0, -3:, -3:, -1]
  
  					assert image.shape == (1, 32, 32, 3)
  					snake_case		:						List[str]								=				np.array([1.00_00, 0.54_26, 0.54_97, 0.22_00, 1.00_00, 1.00_00, 0.56_23, 1.00_00, 0.62_74]							)
  
  					assert np.abs(image_slice.flatten() - expected_slice							).max() < 1E-3
  
  
  			@skip_mps
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					return super().test_save_load_local()
  
  
  			@unittest.skip("non-deterministic pipeline"							)
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					return super().test_inference_batch_single_identical()
  
  
  			@skip_mps
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					return super().test_dict_tuple_outputs_equivalent()
  
  
  			@skip_mps
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					return super().test_save_load_optional_components()
  
  
  
  			@skip_mps
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					return super().test_attention_slicing_forward_pass()
  
  
  
  
  
  
  
  @nightly
  @require_torch_gpu
  class 			lowerCamelCase__    (  unittest.TestCase			):
  
  
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					super().tearDown()
  					gc.collect()
  					torch.cuda.empty_cache()
  
  
  
  			def 							lowerCamelCase_				(     self							):
  
  
  
  					"""simple docstring"""
  
  
  
  
  
  
  
  					snake_case		:						Optional[int]								=				load_image(
  					    "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/"
  					    "repaint/celeba_hq_256.png"							)
  					snake_case		:						Any								=				load_image(
  					    "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/repaint/mask_256.png"							)
  					snake_case		:						List[Any]								=				load_numpy(
  					    "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/"
  					    "repaint/celeba_hq_256_result.npy"							)
  
  					snake_case		:						str								=				"google/ddpm-ema-celebahq-256"
  					snake_case		:						Optional[Any]								=				UNetaDModel.from_pretrained(SCREAMING_SNAKE_CASE							)
  					snake_case		:						Optional[int]								=				RePaintScheduler.from_pretrained(SCREAMING_SNAKE_CASE							)
  
  					snake_case		:						str								=				RePaintPipeline(unet=SCREAMING_SNAKE_CASE				, scheduler=SCREAMING_SNAKE_CASE							).to(SCREAMING_SNAKE_CASE							)
  					repaint.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE							)
  					repaint.enable_attention_slicing()
  
  					snake_case		:						Union[str, Any]								=				torch.manual_seed(0							)
  					snake_case		:						int								=				repaint(
  					    SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE				, num_inference_steps=250				, eta=0.0				, jump_length=10				, jump_n_sample=10				, generator=SCREAMING_SNAKE_CASE				, output_type="np"				, )
  					snake_case		:						List[Any]								=				output.images[0]
  
  					assert image.shape == (256, 256, 3)
  					assert np.abs(expected_image - image							).mean() < 1E-2
  
  