


"""simple docstring"""

import argparse
import collections

import numpy as np
import torch
from flax import traverse_util
from tax import checkpoints

from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration
from transformers.utils import logging


logging.set_verbosity_info()


def lowerCAmelCase_   (					UpperCamelCase__						:			List[Any]					, UpperCamelCase__						:			Tuple					, UpperCamelCase__						:			Optional[Any]			):






 """simple docstring"""







 return params[f'''{prefix}/{prefix}/relpos_bias/rel_embedding'''][:, i, :]


def lowerCAmelCase_   (					UpperCamelCase__						:			Dict					, UpperCamelCase__						:			Any					, UpperCamelCase__						:			Union[str, Any]					, UpperCamelCase__						:			Union[str, Any]="attention"			):






 """simple docstring"""







 __lowercase						=						__lowercase						=						np.ascontiguousarray(params[f'''{prefix}/{prefix}/{layer_name}/key/kernel'''][:, i, :, :]			)
 __lowercase						=						k_tmp.reshape(k_tmp.shape[0]					, k_tmp.shape[1] * k_tmp.shape[2]			)
 __lowercase						=						np.ascontiguousarray(params[f'''{prefix}/{prefix}/{layer_name}/out/kernel'''][:, i, :, :]			)
 __lowercase						=						o_tmp.reshape(o_tmp.shape[0] * o_tmp.shape[1]					, o_tmp.shape[2]			)
 __lowercase						=						np.ascontiguousarray(params[f'''{prefix}/{prefix}/{layer_name}/query/kernel'''][:, i, :, :]			)
 __lowercase						=						q_tmp.reshape(q_tmp.shape[0]					, q_tmp.shape[1] * q_tmp.shape[2]			)
 __lowercase						=						np.ascontiguousarray(params[f'''{prefix}/{prefix}/{layer_name}/value/kernel'''][:, i, :, :]			)
 __lowercase						=						v_tmp.reshape(v_tmp.shape[0]					, v_tmp.shape[1] * v_tmp.shape[2]			)
 return k, o, q, v


def lowerCAmelCase_   (					UpperCamelCase__						:			int					, UpperCamelCase__						:			List[str]					, UpperCamelCase__						:			Optional[Any]					, UpperCamelCase__						:			Tuple=False			):






 """simple docstring"""







 if split_mlp_wi:
  __lowercase						=						params[f'''{prefix}/{prefix}/mlp/wi_0/kernel'''][:, i, :]
  __lowercase						=						params[f'''{prefix}/{prefix}/mlp/wi_1/kernel'''][:, i, :]
  __lowercase						=						(wi_a, wi_a)
 else:
  __lowercase						=						params[f'''{prefix}/{prefix}/mlp/wi/kernel'''][:, i, :]

 __lowercase						=						params[f'''{prefix}/{prefix}/mlp/wo/kernel'''][:, i, :]
 return wi, wo


def lowerCAmelCase_   (					UpperCamelCase__						:			List[Any]					, UpperCamelCase__						:			Dict					, UpperCamelCase__						:			Optional[Any]					, UpperCamelCase__						:			Dict			):






 """simple docstring"""







 return params[f'''{prefix}/{prefix}/{layer_name}/scale'''][:, i]


def lowerCAmelCase_   (					UpperCamelCase__						:			dict					, *, UpperCamelCase__						:			int					, UpperCamelCase__						:			bool					, UpperCamelCase__						:			bool = False			):






 """simple docstring"""







 __lowercase						=						traverse_util.flatten_dict(variables["""target"""]			)
 __lowercase						=						{"""/""".join(UpperCamelCase__			): v for k, v in old.items()}

 # v1.1 models have a gated GeLU with wi_0 and wi_1 instead of wi
 __lowercase						=						"""encoder/encoder/mlp/wi_0/kernel""" in old
 print("""Split MLP:"""					, UpperCamelCase__			)

 __lowercase						=						collections.OrderedDict()

 # Shared embeddings.
 __lowercase						=						old["""token_embedder/embedding"""]

 # Encoder.
 for i in range(UpperCamelCase__			):
  # Block i, layer 0 (Self Attention).
  __lowercase						=						tax_layer_norm_lookup(UpperCamelCase__					, UpperCamelCase__					, """encoder"""					, """pre_attention_layer_norm"""			)
  __lowercase				,		__lowercase				,		__lowercase				,		__lowercase						=						tax_attention_lookup(UpperCamelCase__					, UpperCamelCase__					, """encoder"""					, """attention"""			)
  __lowercase						=						layer_norm
  __lowercase						=						k.T
  __lowercase						=						o.T
  __lowercase						=						q.T
  __lowercase						=						v.T

  # Block i, layer 1 (MLP).
  __lowercase						=						tax_layer_norm_lookup(UpperCamelCase__					, UpperCamelCase__					, """encoder"""					, """pre_mlp_layer_norm"""			)
  __lowercase				,		__lowercase						=						tax_mlp_lookup(UpperCamelCase__					, UpperCamelCase__					, """encoder"""					, UpperCamelCase__			)
  __lowercase						=						layer_norm
  if split_mlp_wi:
   __lowercase						=						wi[0].T
   __lowercase						=						wi[1].T
  else:
   __lowercase						=						wi.T
  __lowercase						=						wo.T
  if scalable_attention:
   # convert the rel_embedding of each layer
   __lowercase						=						tax_relpos_bias_lookup(
       UpperCamelCase__					, UpperCamelCase__					, """encoder"""			).T

 __lowercase						=						old["""encoder/encoder_norm/scale"""]

 if not scalable_attention:
  __lowercase						=						tax_relpos_bias_lookup(
      UpperCamelCase__					, 0					, """encoder"""			).T
  __lowercase						=						tax_relpos_bias_lookup(
      UpperCamelCase__					, 0					, """decoder"""			).T

 if not is_encoder_only:
  # Decoder.
  for i in range(UpperCamelCase__			):
   # Block i, layer 0 (Self Attention).
   __lowercase						=						tax_layer_norm_lookup(UpperCamelCase__					, UpperCamelCase__					, """decoder"""					, """pre_self_attention_layer_norm"""			)
   __lowercase				,		__lowercase				,		__lowercase				,		__lowercase						=						tax_attention_lookup(UpperCamelCase__					, UpperCamelCase__					, """decoder"""					, """self_attention"""			)
   __lowercase						=						layer_norm
   __lowercase						=						k.T
   __lowercase						=						o.T
   __lowercase						=						q.T
   __lowercase						=						v.T

   # Block i, layer 1 (Cross Attention).
   __lowercase						=						tax_layer_norm_lookup(UpperCamelCase__					, UpperCamelCase__					, """decoder"""					, """pre_cross_attention_layer_norm"""			)
   __lowercase				,		__lowercase				,		__lowercase				,		__lowercase						=						tax_attention_lookup(UpperCamelCase__					, UpperCamelCase__					, """decoder"""					, """encoder_decoder_attention"""			)
   __lowercase						=						layer_norm
   __lowercase						=						k.T
   __lowercase						=						o.T
   __lowercase						=						q.T
   __lowercase						=						v.T

   # Block i, layer 2 (MLP).
   __lowercase						=						tax_layer_norm_lookup(UpperCamelCase__					, UpperCamelCase__					, """decoder"""					, """pre_mlp_layer_norm"""			)
   __lowercase				,		__lowercase						=						tax_mlp_lookup(UpperCamelCase__					, UpperCamelCase__					, """decoder"""					, UpperCamelCase__			)
   __lowercase						=						layer_norm
   if split_mlp_wi:
    __lowercase						=						wi[0].T
    __lowercase						=						wi[1].T
   else:
    __lowercase						=						wi.T
   __lowercase						=						wo.T

   if scalable_attention:
    # convert the rel_embedding of each layer
    __lowercase						=						tax_relpos_bias_lookup(UpperCamelCase__					, UpperCamelCase__					, """decoder"""			).T

  __lowercase						=						old["""decoder/decoder_norm/scale"""]

  # LM Head (only in v1.1 checkpoints, in v1.0 embeddings are used instead)
  if "decoder/logits_dense/kernel" in old:
   __lowercase						=						old["""decoder/logits_dense/kernel"""].T

 return new


def lowerCAmelCase_   (					UpperCamelCase__						:			List[Any]					, UpperCamelCase__						:			bool			):






 """simple docstring"""







 __lowercase						=						collections.OrderedDict([(k, torch.from_numpy(v.copy()			)) for (k, v) in converted_params.items()]			)

 # Add what is missing.
 if "encoder.embed_tokens.weight" not in state_dict:
  __lowercase						=						state_dict["""shared.weight"""]

 if not is_encoder_only:
  if "decoder.embed_tokens.weight" not in state_dict:
   __lowercase						=						state_dict["""shared.weight"""]

  if "lm_head.weight" not in state_dict:  # For old 1.0 models.
   print("""Using shared word embeddings as lm_head."""			)
   __lowercase						=						state_dict["""shared.weight"""]

 return state_dict


def lowerCAmelCase_   (					UpperCamelCase__						:			Optional[Any]					, UpperCamelCase__						:			Tuple					, UpperCamelCase__						:			Optional[Any]					, UpperCamelCase__						:			Any					, UpperCamelCase__						:			Tuple			):






 """simple docstring"""







 __lowercase						=						checkpoints.load_tax_checkpoint(UpperCamelCase__			)
 __lowercase						=						convert_tax_to_pytorch(
     UpperCamelCase__					, num_layers=config.num_layers					, is_encoder_only=UpperCamelCase__					, scalable_attention=UpperCamelCase__			)
 __lowercase						=						make_state_dict(UpperCamelCase__					, UpperCamelCase__			)
 model.load_state_dict(UpperCamelCase__					, strict=UpperCamelCase__			)


def lowerCAmelCase_   (					UpperCamelCase__						:			Tuple					, UpperCamelCase__						:			Any					, UpperCamelCase__						:			List[Any]					, UpperCamelCase__						:			bool = False					, UpperCamelCase__						:			bool = False					, ):






 """simple docstring"""







 __lowercase						=						MTaConfig.from_json_file(UpperCamelCase__			)
 print(f'''Building PyTorch model from configuration: {config}'''			)
 # Non-v1.1 checkpoints could also use T5Model, but this works for all.
 # The v1.0 checkpoints will simply have an LM head that is the word embeddings.
 if is_encoder_only:
  __lowercase						=						UMTaEncoderModel(UpperCamelCase__			)
 else:
  __lowercase						=						UMTaForConditionalGeneration(UpperCamelCase__			)

 # Load weights from tf checkpoint
 load_tax_weights_in_ta(UpperCamelCase__					, UpperCamelCase__					, UpperCamelCase__					, UpperCamelCase__					, UpperCamelCase__			)

 # Save pytorch-model
 print(f'''Save PyTorch model to {pytorch_dump_path}'''			)
 model.save_pretrained(UpperCamelCase__			)

 # Verify that we can load the checkpoint.
 model.from_pretrained(UpperCamelCase__			)
 print("""Done"""			)


if __name__ == "__main__":
       UpperCAmelCase__					=argparse.ArgumentParser(description="Converts a native T5X checkpoint into a PyTorch checkpoint.")
       # Required parameters
       parser.add_argument(
           "--t5x_checkpoint_path", default=None, type=str, required=True, help="Path to the T5X checkpoint."
       )
       parser.add_argument(
           "--config_file",
           default=None,
           type=str,
           required=True,
           help="The config json file corresponding to the pre-trained T5 model.\nThis specifies the model architecture.",
       )
       parser.add_argument(
           "--pytorch_dump_path", default=None, type=str, required=True, help="Path to the output PyTorch model."
       )
       parser.add_argument(
           "--is_encoder_only", action="store_true", help="Check if the model is encoder-decoder model", default=False
       )
       parser.add_argument(
           "--scalable_attention",
           action="store_true",
           help="Whether the model uses scaled attention (umt5 model)",
           default=False,
       )
       UpperCAmelCase__					=parser.parse_args()
       convert_tax_checkpoint_to_pytorch(
           args.tax_checkpoint_path,
           args.config_file,
           args.pytorch_dump_path,
           args.is_encoder_only,
           args.scalable_attention,
       )




"""simple docstring"""

import gc
import random
import unittest

import torch

from diffusers import (
    IFImgaImgPipeline,
    IFImgaImgSuperResolutionPipeline,
    IFInpaintingPipeline,
    IFInpaintingSuperResolutionPipeline,
    IFPipeline,
    IFSuperResolutionPipeline,
)
from diffusers.models.attention_processor import AttnAddedKVProcessor
from diffusers.utils.import_utils import is_xformers_available
from diffusers.utils.testing_utils import floats_tensor, load_numpy, require_torch_gpu, skip_mps, slow, torch_device

from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS
from ..test_pipelines_common import PipelineTesterMixin, assert_mean_pixel_difference
from . import IFPipelineTesterMixin





@skip_mps
class  lowerCamelCase__    (		_a      , _a      , unittest.TestCase     ):
      a			:  Any           =		IFPipeline
      a			:  str           =		TEXT_TO_IMAGE_PARAMS - {"""width""", """height""", """latents"""}
      a			:  Dict           =		TEXT_TO_IMAGE_BATCH_PARAMS
      a			:  int           =		PipelineTesterMixin.required_optional_params - {"""latents"""}
      def SCREAMING_SNAKE_CASE_						(		self						:						List[Any]				):






       '''simple docstring'''


       return self._get_dummy_components()
      def SCREAMING_SNAKE_CASE_						(		self						:						Any   ,							A_						:						int   ,							A_						:						Dict=0				):






       '''simple docstring'''


       if str(A_				).startswith("""mps"""				):
        __lowercase						=						torch.manual_seed(A_				)
       else:
        __lowercase						=						torch.Generator(device=A_				).manual_seed(A_				)

       __lowercase						=						{
           """prompt""": """A painting of a squirrel eating a burger""",
           """generator""": generator,
           """num_inference_steps""": 2,
           """output_type""": """numpy""",
       }

       return inputs
      def SCREAMING_SNAKE_CASE_						(		self						:						Union[str, Any]				):






       '''simple docstring'''


       self._test_save_load_optional_components()
      @unittest.skipIf(torch_device != """cuda"""   ,							reason="""float16 requires CUDA"""				)
      def SCREAMING_SNAKE_CASE_						(		self						:						List[str]				):






       '''simple docstring'''


       super().test_save_load_floataa(expected_max_diff=1e-1				)
      def SCREAMING_SNAKE_CASE_						(		self						:						List[Any]				):






       '''simple docstring'''


       self._test_attention_slicing_forward_pass(expected_max_diff=1e-2				)
      def SCREAMING_SNAKE_CASE_						(		self						:						List[str]				):






       '''simple docstring'''


       self._test_save_load_local()
      def SCREAMING_SNAKE_CASE_						(		self						:						Union[str, Any]				):






       '''simple docstring'''


       self._test_inference_batch_single_identical(
           expected_max_diff=1e-2   ,							)






      @unittest.skipIf(
          torch_device != """cuda""" or not is_xformers_available()   ,							reason="""XFormers attention is only available with CUDA and `xformers` installed"""   ,							)
      def SCREAMING_SNAKE_CASE_						(		self						:						Tuple				):






       '''simple docstring'''


       self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1e-3				)






@slow
@require_torch_gpu
class  lowerCamelCase__    (		unittest.TestCase     ):
      def SCREAMING_SNAKE_CASE_						(		self						:						str				):






       '''simple docstring'''


       super().tearDown()
       gc.collect()
       torch.cuda.empty_cache()
      def SCREAMING_SNAKE_CASE_						(		self						:						Union[str, Any]				):






       '''simple docstring'''


       __lowercase						=						IFPipeline.from_pretrained("""DeepFloyd/IF-I-XL-v1.0"""   ,							variant="""fp16"""   ,							torch_dtype=torch.floataa				)

       __lowercase						=						IFSuperResolutionPipeline.from_pretrained(
           """DeepFloyd/IF-II-L-v1.0"""   ,							variant="""fp16"""   ,							torch_dtype=torch.floataa   ,							text_encoder=A_   ,							tokenizer=A_				)

       # pre compute text embeddings and remove T5 to save memory

       pipe_a.text_encoder.to("""cuda"""				)

       __lowercase				,		__lowercase						=						pipe_a.encode_prompt("""anime turtle"""   ,							device="""cuda"""				)

       del pipe_a.tokenizer
       del pipe_a.text_encoder
       gc.collect()

       __lowercase						=						None
       __lowercase						=						None

       pipe_a.enable_model_cpu_offload()
       pipe_a.enable_model_cpu_offload()

       pipe_a.unet.set_attn_processor(AttnAddedKVProcessor()				)
       pipe_a.unet.set_attn_processor(AttnAddedKVProcessor()				)

       self._test_if(A_   ,							A_   ,							A_   ,							A_				)

       pipe_a.remove_all_hooks()
       pipe_a.remove_all_hooks()

       # img2img

       __lowercase						=						IFImgaImgPipeline(**pipe_a.components				)
       __lowercase						=						IFImgaImgSuperResolutionPipeline(**pipe_a.components				)

       pipe_a.enable_model_cpu_offload()
       pipe_a.enable_model_cpu_offload()

       pipe_a.unet.set_attn_processor(AttnAddedKVProcessor()				)
       pipe_a.unet.set_attn_processor(AttnAddedKVProcessor()				)

       self._test_if_imgaimg(A_   ,							A_   ,							A_   ,							A_				)

       pipe_a.remove_all_hooks()
       pipe_a.remove_all_hooks()

       # inpainting

       __lowercase						=						IFInpaintingPipeline(**pipe_a.components				)
       __lowercase						=						IFInpaintingSuperResolutionPipeline(**pipe_a.components				)

       pipe_a.enable_model_cpu_offload()
       pipe_a.enable_model_cpu_offload()

       pipe_a.unet.set_attn_processor(AttnAddedKVProcessor()				)
       pipe_a.unet.set_attn_processor(AttnAddedKVProcessor()				)

       self._test_if_inpainting(A_   ,							A_   ,							A_   ,							A_				)
      def SCREAMING_SNAKE_CASE_						(		self						:						Optional[int]   ,							A_						:						Any   ,							A_						:						int   ,							A_						:						str   ,							A_						:						Dict				):






       '''simple docstring'''


       _start_torch_memory_measurement()

       __lowercase						=						torch.Generator(device="""cpu"""				).manual_seed(0				)
       __lowercase						=						pipe_a(
           prompt_embeds=A_   ,							negative_prompt_embeds=A_   ,							num_inference_steps=2   ,							generator=A_   ,							output_type="""np"""   ,							)

       __lowercase						=						output.images[0]

       assert image.shape == (6_4, 6_4, 3)

       __lowercase						=						torch.cuda.max_memory_allocated()
       assert mem_bytes < 1_3 * 1_0**9

       __lowercase						=						load_numpy(
           """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/if/test_if.npy"""				)
       assert_mean_pixel_difference(A_   ,							A_				)

       # pipeline 2

       _start_torch_memory_measurement()

       __lowercase						=						torch.Generator(device="""cpu"""				).manual_seed(0				)

       __lowercase						=						floats_tensor((1, 3, 6_4, 6_4)   ,							rng=random.Random(0				)				).to(A_				)

       __lowercase						=						pipe_a(
           prompt_embeds=A_   ,							negative_prompt_embeds=A_   ,							image=A_   ,							generator=A_   ,							num_inference_steps=2   ,							output_type="""np"""   ,							)

       __lowercase						=						output.images[0]

       assert image.shape == (2_5_6, 2_5_6, 3)

       __lowercase						=						torch.cuda.max_memory_allocated()
       assert mem_bytes < 4 * 1_0**9

       __lowercase						=						load_numpy(
           """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/if/test_if_superresolution_stage_II.npy"""				)
       assert_mean_pixel_difference(A_   ,							A_				)
      def SCREAMING_SNAKE_CASE_						(		self						:						Optional[Any]   ,							A_						:						Tuple   ,							A_						:						List[Any]   ,							A_						:						List[Any]   ,							A_						:						Any				):






       '''simple docstring'''


       _start_torch_memory_measurement()

       __lowercase						=						floats_tensor((1, 3, 6_4, 6_4)   ,							rng=random.Random(0				)				).to(A_				)

       __lowercase						=						torch.Generator(device="""cpu"""				).manual_seed(0				)

       __lowercase						=						pipe_a(
           prompt_embeds=A_   ,							negative_prompt_embeds=A_   ,							image=A_   ,							num_inference_steps=2   ,							generator=A_   ,							output_type="""np"""   ,							)

       __lowercase						=						output.images[0]

       assert image.shape == (6_4, 6_4, 3)

       __lowercase						=						torch.cuda.max_memory_allocated()
       assert mem_bytes < 1_0 * 1_0**9

       __lowercase						=						load_numpy(
           """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/if/test_if_img2img.npy"""				)
       assert_mean_pixel_difference(A_   ,							A_				)

       # pipeline 2

       _start_torch_memory_measurement()

       __lowercase						=						torch.Generator(device="""cpu"""				).manual_seed(0				)

       __lowercase						=						floats_tensor((1, 3, 2_5_6, 2_5_6)   ,							rng=random.Random(0				)				).to(A_				)
       __lowercase						=						floats_tensor((1, 3, 6_4, 6_4)   ,							rng=random.Random(0				)				).to(A_				)

       __lowercase						=						pipe_a(
           prompt_embeds=A_   ,							negative_prompt_embeds=A_   ,							image=A_   ,							original_image=A_   ,							generator=A_   ,							num_inference_steps=2   ,							output_type="""np"""   ,							)

       __lowercase						=						output.images[0]

       assert image.shape == (2_5_6, 2_5_6, 3)

       __lowercase						=						torch.cuda.max_memory_allocated()
       assert mem_bytes < 4 * 1_0**9

       __lowercase						=						load_numpy(
           """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/if/test_if_img2img_superresolution_stage_II.npy"""				)
       assert_mean_pixel_difference(A_   ,							A_				)






      def SCREAMING_SNAKE_CASE_						(		self						:						List[str]   ,							A_						:						List[Any]   ,							A_						:						str   ,							A_						:						List[Any]   ,							A_						:						List[Any]				):






       '''simple docstring'''


       _start_torch_memory_measurement()

       __lowercase						=						floats_tensor((1, 3, 6_4, 6_4)   ,							rng=random.Random(0				)				).to(A_				)
       __lowercase						=						floats_tensor((1, 3, 6_4, 6_4)   ,							rng=random.Random(1				)				).to(A_				)

       __lowercase						=						torch.Generator(device="""cpu"""				).manual_seed(0				)
       __lowercase						=						pipe_a(
           prompt_embeds=A_   ,							negative_prompt_embeds=A_   ,							image=A_   ,							mask_image=A_   ,							num_inference_steps=2   ,							generator=A_   ,							output_type="""np"""   ,							)

       __lowercase						=						output.images[0]

       assert image.shape == (6_4, 6_4, 3)

       __lowercase						=						torch.cuda.max_memory_allocated()
       assert mem_bytes < 1_0 * 1_0**9

       __lowercase						=						load_numpy(
           """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/if/test_if_inpainting.npy"""				)
       assert_mean_pixel_difference(A_   ,							A_				)

       # pipeline 2

       _start_torch_memory_measurement()

       __lowercase						=						torch.Generator(device="""cpu"""				).manual_seed(0				)

       __lowercase						=						floats_tensor((1, 3, 6_4, 6_4)   ,							rng=random.Random(0				)				).to(A_				)
       __lowercase						=						floats_tensor((1, 3, 2_5_6, 2_5_6)   ,							rng=random.Random(0				)				).to(A_				)
       __lowercase						=						floats_tensor((1, 3, 2_5_6, 2_5_6)   ,							rng=random.Random(1				)				).to(A_				)

       __lowercase						=						pipe_a(
           prompt_embeds=A_   ,							negative_prompt_embeds=A_   ,							image=A_   ,							mask_image=A_   ,							original_image=A_   ,							generator=A_   ,							num_inference_steps=2   ,							output_type="""np"""   ,							)

       __lowercase						=						output.images[0]

       assert image.shape == (2_5_6, 2_5_6, 3)

       __lowercase						=						torch.cuda.max_memory_allocated()
       assert mem_bytes < 4 * 1_0**9

       __lowercase						=						load_numpy(
           """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/if/test_if_inpainting_superresolution_stage_II.npy"""				)
       assert_mean_pixel_difference(A_   ,							A_				)






def lowerCAmelCase_   (					):






 """simple docstring"""







 torch.cuda.empty_cache()
 torch.cuda.reset_max_memory_allocated()
 torch.cuda.reset_peak_memory_stats()
