


"""simple docstring"""







import json
import os
from functools import lru_cache
from typing import TYPE_CHECKING, List, Optional, Tuple

import regex as re

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


if TYPE_CHECKING:
 from transformers.pipelines.conversational import Conversation

__lowercase    					=      logging.get_logger(__name__)


__lowercase    					=      {
    """vocab_file""": """vocab.json""",
    """merges_file""": """merges.txt""",
    """tokenizer_config_file""": """tokenizer_config.json""",
}

__lowercase    					=      {
    """vocab_file""": {"""facebook/blenderbot-3B""": """https://huggingface.co/facebook/blenderbot-3B/resolve/main/vocab.json"""},
    """merges_file""": {"""facebook/blenderbot-3B""": """https://huggingface.co/facebook/blenderbot-3B/resolve/main/merges.txt"""},
    """tokenizer_config_file""": {
        """facebook/blenderbot-3B""": """https://huggingface.co/facebook/blenderbot-3B/resolve/main/tokenizer_config.json"""
    },
}

__lowercase    					=      {"""facebook/blenderbot-3B""": 128}


@lru_cache()
# Copied from transformers.models.roberta.tokenization_roberta.bytes_to_unicode
def      lowercase			(				)->      List[Any]:
  '''simple docstring'''







  a						:		int      							=			(
      list(range(ord("!"       )  ,   ord("~"       ) + 1       )       ) + list(range(ord("¡"       )  ,   ord("¬"       ) + 1       )       ) + list(range(ord("®"       )  ,   ord("ÿ"       ) + 1       )       )
  )
  a						:		Any      							=			bs[:]
  a						:		Tuple      							=			0
  for b in range(2**8       ):
    if b not in bs:
      bs.append(A_       )
      cs.append(2**8 + n       )
      n += 1
  a						:		Optional[Any]      							=			[chr(A_       ) for n in cs]
  return dict(zip(A_  ,   A_       )       )


def      lowercase			(				A_       )->      Dict:
  '''simple docstring'''







  a						:		List[Any]      							=			set()
  a						:		Union[str, Any]      							=			word[0]
  for char in word[1:]:
    pairs.add((prev_char, char)       )
    a						:		int      							=			char
  return pairs







class 						_A  (  _a  ):







    """simple docstring"""




    UpperCAmelCase       :							Optional[Any]	=       VOCAB_FILES_NAMES
    UpperCAmelCase       :							Optional[Any]	=       PRETRAINED_VOCAB_FILES_MAP
    UpperCAmelCase       :							str	=       PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
    UpperCAmelCase       :							List[str]	=       ["""input_ids""", """attention_mask"""]






    def __init__(					self				:    Dict				, __UpperCAmelCase				:    Tuple				, __UpperCAmelCase				:    List[str]				, __UpperCAmelCase				:    Dict="replace"				, __UpperCAmelCase				:    Tuple="<s>"				, __UpperCAmelCase				:    Any="</s>"				, __UpperCAmelCase				:    List[Any]="</s>"				, __UpperCAmelCase				:    str="<s>"				, __UpperCAmelCase				:    Optional[Any]="<unk>"				, __UpperCAmelCase				:    Optional[int]="<pad>"				, __UpperCAmelCase				:    Optional[Any]="<mask>"				, __UpperCAmelCase				:    Any=False				, **__UpperCAmelCase				:    List[Any]				, ):
      a						:		Tuple      							=			AddedToken(__UpperCAmelCase				, lstrip=__UpperCAmelCase				, rstrip=__UpperCAmelCase) if isinstance(__UpperCAmelCase				, __UpperCAmelCase) else bos_token
      a						:		Union[str, Any]      							=			AddedToken(__UpperCAmelCase				, lstrip=__UpperCAmelCase				, rstrip=__UpperCAmelCase) if isinstance(__UpperCAmelCase				, __UpperCAmelCase) else eos_token
      a						:		Optional[int]      							=			AddedToken(__UpperCAmelCase				, lstrip=__UpperCAmelCase				, rstrip=__UpperCAmelCase) if isinstance(__UpperCAmelCase				, __UpperCAmelCase) else sep_token
      a						:		Optional[int]      							=			AddedToken(__UpperCAmelCase				, lstrip=__UpperCAmelCase				, rstrip=__UpperCAmelCase) if isinstance(__UpperCAmelCase				, __UpperCAmelCase) else cls_token
      a						:		Optional[Any]      							=			AddedToken(__UpperCAmelCase				, lstrip=__UpperCAmelCase				, rstrip=__UpperCAmelCase) if isinstance(__UpperCAmelCase				, __UpperCAmelCase) else unk_token
      a						:		Tuple      							=			AddedToken(__UpperCAmelCase				, lstrip=__UpperCAmelCase				, rstrip=__UpperCAmelCase) if isinstance(__UpperCAmelCase				, __UpperCAmelCase) else pad_token

      # Mask token behave like a normal word, i.e. include the space before it
      a						:		Dict      							=			AddedToken(__UpperCAmelCase				, lstrip=__UpperCAmelCase				, rstrip=__UpperCAmelCase) if isinstance(__UpperCAmelCase				, __UpperCAmelCase) else mask_token

      super().__init__(
          errors=__UpperCAmelCase				, bos_token=__UpperCAmelCase				, eos_token=__UpperCAmelCase				, unk_token=__UpperCAmelCase				, sep_token=__UpperCAmelCase				, cls_token=__UpperCAmelCase				, pad_token=__UpperCAmelCase				, mask_token=__UpperCAmelCase				, add_prefix_space=__UpperCAmelCase				, **__UpperCAmelCase				, )

      with open(__UpperCAmelCase				, encoding="utf-8") as vocab_handle:
        a						:		str      							=			json.load(__UpperCAmelCase)
      a						:		str      							=			{v: k for k, v in self.encoder.items()}
      a						:		str      							=			errors  # how to handle errors in decoding
      a						:		str      							=			bytes_to_unicode()
      a						:		Union[str, Any]      							=			{v: k for k, v in self.byte_encoder.items()}
      with open(__UpperCAmelCase				, encoding="utf-8") as merges_handle:
        a						:		Optional[Any]      							=			merges_handle.read().split("\n")[1:-1]
      a						:		List[str]      							=			[tuple(merge.split()) for merge in bpe_merges]
      a						:		Optional[Any]      							=			dict(zip(__UpperCAmelCase				, range(len(__UpperCAmelCase))))
      a						:		Any      							=			{}
      a						:		Dict      							=			add_prefix_space

      # Should have added re.IGNORECASE so BPE merges can happen for capitalized versions of contractions
      a						:		str      							=			re.compile(r"'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+")






    @property
    # Copied from transformers.models.roberta.tokenization_roberta.RobertaTokenizer.vocab_size with Roberta->Blenderbot, RoBERTa->Blenderbot
    def 	__snake_case							(					self				:    Tuple):
      return len(self.encoder)






    def 	__snake_case							(					self				:    Optional[Any]):
      return dict(self.encoder				, **self.added_tokens_encoder)






    def 	__snake_case							(					self				:    int				, __UpperCAmelCase				:    str):
      if token in self.cache:
        return self.cache[token]
      a						:		str      							=			tuple(__UpperCAmelCase)
      a						:		Dict      							=			get_pairs(__UpperCAmelCase)

      if not pairs:
        return token

      while True:
        a						:		Optional[int]      							=			min(__UpperCAmelCase				, key=lambda __UpperCAmelCase: self.bpe_ranks.get(__UpperCAmelCase				, float("inf")))
        if bigram not in self.bpe_ranks:
          break
        a							,		a						:		str      							=			bigram
        a						:		Optional[int]      							=			[]
        a						:		List[str]      							=			0
        while i < len(__UpperCAmelCase):
          try:
            a						:		List[str]      							=			word.index(__UpperCAmelCase				, __UpperCAmelCase)
          except ValueError:
            new_word.extend(word[i:])
            break
          else:
            new_word.extend(word[i:j])
            a						:		int      							=			j

          if word[i] == first and i < len(__UpperCAmelCase) - 1 and word[i + 1] == second:
            new_word.append(first + second)
            i += 2
          else:
            new_word.append(word[i])
            i += 1
        a						:		int      							=			tuple(__UpperCAmelCase)
        a						:		List[Any]      							=			new_word
        if len(__UpperCAmelCase) == 1:
          break
        else:
          a						:		Dict      							=			get_pairs(__UpperCAmelCase)
      a						:		Dict      							=			" ".join(__UpperCAmelCase)
      a						:		str      							=			word
      return word






    def 	__snake_case							(					self				:    Optional[Any]				, __UpperCAmelCase				:    Optional[Any]):
      a						:		Optional[Any]      							=			[]
      for token in re.findall(self.pat				, __UpperCAmelCase):
        a						:		Dict      							=			"".join(
            self.byte_encoder[b] for b in token.encode("utf-8"))  # Maps all our bytes to unicode strings, avoiding control tokens of the BPE (spaces in our case)
        bpe_tokens.extend(bpe_token for bpe_token in self.bpe(__UpperCAmelCase).split(" "))
      return bpe_tokens






    def 	__snake_case							(					self				:    int				, __UpperCAmelCase				:    List[Any]):
      return self.encoder.get(__UpperCAmelCase				, self.encoder.get(self.unk_token))






    def 	__snake_case							(					self				:    Tuple				, __UpperCAmelCase				:    Union[str, Any]):
      return self.decoder.get(__UpperCAmelCase)






    def 	__snake_case							(					self				:    List[Any]				, __UpperCAmelCase				:    Any):
      a						:		Tuple      							=			"".join(__UpperCAmelCase)
      a						:		Optional[Any]      							=			bytearray([self.byte_decoder[c] for c in text]).decode("utf-8"				, errors=self.errors)
      return text






    def 	__snake_case							(					self				:    List[str]				, __UpperCAmelCase				:    str				, __UpperCAmelCase				:    Optional[str] = None):
      if not os.path.isdir(__UpperCAmelCase):
        logger.error(f'''Vocabulary path ({save_directory}) should be a directory''')
        return
      a						:		Dict      							=			os.path.join(
          __UpperCAmelCase				, (filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"])
      a						:		int      							=			os.path.join(
          __UpperCAmelCase				, (filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["merges_file"])

      with open(__UpperCAmelCase				, "w"				, encoding="utf-8") as f:
        f.write(json.dumps(self.encoder				, indent=2				, sort_keys=__UpperCAmelCase				, ensure_ascii=__UpperCAmelCase) + "\n")

      a						:		str      							=			0
      with open(__UpperCAmelCase				, "w"				, encoding="utf-8") as writer:
        writer.write("#version: 0.2\n")
        for bpe_tokens, token_index in sorted(self.bpe_ranks.items()				, key=lambda __UpperCAmelCase: kv[1]):
          if index != token_index:
            logger.warning(
                f'''Saving vocabulary to {merge_file}: BPE merge indices are not consecutive.'''
                " Please check that the tokenizer is not corrupted!")
            a						:		List[str]      							=			token_index
          writer.write(" ".join(__UpperCAmelCase) + "\n")
          index += 1

      return vocab_file, merge_file






    def 	__snake_case							(					self				:    str				, __UpperCAmelCase				:    List[int]				, __UpperCAmelCase				:    Optional[List[int]] = None				, __UpperCAmelCase				:    bool = False):
      if already_has_special_tokens:
        return super().get_special_tokens_mask(
            token_ids_a=__UpperCAmelCase				, token_ids_a=__UpperCAmelCase				, already_has_special_tokens=__UpperCAmelCase)

      if token_ids_a is None:
        return [1] + ([0] * len(__UpperCAmelCase)) + [1]
      return [1] + ([0] * len(__UpperCAmelCase)) + [1, 1] + ([0] * len(__UpperCAmelCase)) + [1]






    def 	__snake_case							(					self				:    Any				, __UpperCAmelCase				:    List[int]				, __UpperCAmelCase				:    Optional[List[int]] = None):
      a						:		Union[str, Any]      							=			[self.sep_token_id]
      a						:		Optional[Any]      							=			[self.cls_token_id]

      if token_ids_a is None:
        return len(cls + token_ids_a + sep) * [0]
      return len(cls + token_ids_a + sep + sep + token_ids_a + sep) * [0]






    def 	__snake_case							(					self				:    int				, __UpperCAmelCase				:    Union[str, Any]				, __UpperCAmelCase				:    Optional[Any]=False				, **__UpperCAmelCase				:    List[Any]):
      a						:		Any      							=			kwargs.pop("add_prefix_space"				, self.add_prefix_space)
      if (is_split_into_words or add_prefix_space) and (len(__UpperCAmelCase) > 0 and not text[0].isspace()):
        a						:		List[Any]      							=			" " + text
      return (text, kwargs)






    def 	__snake_case							(					self				:    int				, __UpperCAmelCase				:    List[int]				, __UpperCAmelCase				:    Optional[List[int]] = None):
      return token_ids_a + [self.eos_token_id]






    def 	__snake_case							(					self				:    Union[str, Any]				, __UpperCAmelCase				:    "Conversation"):
      a						:		List[str]      							=			[]
      for is_user, text in conversation.iter_texts():
        if is_user:
          # We need to space prefix as it's being done within blenderbot
          inputs.append(" " + text)
        else:
          # Generated responses should contain them already.
          inputs.append(__UpperCAmelCase)

      a						:		Tuple      							=			"  ".join(__UpperCAmelCase)
      a						:		Optional[Any]      							=			self.encode(__UpperCAmelCase)
      if len(__UpperCAmelCase) > self.model_max_length:
        a						:		int      							=			input_ids[-self.model_max_length :]
        logger.warning(f'''Trimmed input from conversation as it was longer than {self.model_max_length} tokens.''')
      return input_ids










"""simple docstring"""







import gc
import random
import unittest

import numpy as np
import torch
from PIL import Image
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import AutoencoderKL, PNDMScheduler, StableDiffusionInpaintPipeline, UNetaDConditionModel
from diffusers.utils import floats_tensor, load_image, load_numpy, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow

from ..pipeline_params import TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS, TEXT_GUIDED_IMAGE_INPAINTING_PARAMS
from ..test_pipelines_common import PipelineKarrasSchedulerTesterMixin, PipelineLatentTesterMixin, PipelineTesterMixin


enable_full_determinism()






class 						_A  (  _a    ,_a    ,_a    ,unittest.TestCase  ):







    """simple docstring"""




    UpperCAmelCase       :							str	=       StableDiffusionInpaintPipeline
    UpperCAmelCase       :							Optional[Any]	=       TEXT_GUIDED_IMAGE_INPAINTING_PARAMS
    UpperCAmelCase       :							Any	=       TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS
    UpperCAmelCase       :							Union[str, Any]	=       frozenset(
        []  )  # TO-DO: update image_params once pipeline is refactored with VaeImageProcessor.preprocess
    UpperCAmelCase       :							int	=       frozenset([]  )






    def 	__snake_case							(					self				:    Dict):
      torch.manual_seed(0)
      a						:		List[Any]      							=			UNetaDConditionModel(
          block_out_channels=(32, 64)				, layers_per_block=2				, sample_size=32				, in_channels=9				, out_channels=4				, down_block_types=("DownBlock2D", "CrossAttnDownBlock2D")				, up_block_types=("CrossAttnUpBlock2D", "UpBlock2D")				, cross_attention_dim=32				, attention_head_dim=(2, 4)				, use_linear_projection=__UpperCAmelCase				, )
      a						:		Tuple      							=			PNDMScheduler(skip_prk_steps=__UpperCAmelCase)
      torch.manual_seed(0)
      a						:		str      							=			AutoencoderKL(
          block_out_channels=[32, 64]				, in_channels=3				, out_channels=3				, down_block_types=["DownEncoderBlock2D", "DownEncoderBlock2D"]				, up_block_types=["UpDecoderBlock2D", "UpDecoderBlock2D"]				, latent_channels=4				, sample_size=128				, )
      torch.manual_seed(0)
      a						:		List[str]      							=			CLIPTextConfig(
          bos_token_id=0				, eos_token_id=2				, hidden_size=32				, intermediate_size=37				, layer_norm_eps=1e-05				, num_attention_heads=4				, num_hidden_layers=5				, pad_token_id=1				, vocab_size=1000				, hidden_act="gelu"				, projection_dim=512				, )
      a						:		Any      							=			CLIPTextModel(__UpperCAmelCase)
      a						:		List[str]      							=			CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip")

      a						:		Optional[Any]      							=			{
          "unet": unet,
          "scheduler": scheduler,
          "vae": vae,
          "text_encoder": text_encoder,
          "tokenizer": tokenizer,
          "safety_checker": None,
          "feature_extractor": None,
      }
      return components






    def 	__snake_case							(					self				:    Union[str, Any]				, __UpperCAmelCase				:    Any				, __UpperCAmelCase				:    Union[str, Any]=0):
      # TODO: use tensor inputs instead of PIL, this is here just to leave the old expected_slices untouched
      a						:		Dict      							=			floats_tensor((1, 3, 32, 32)				, rng=random.Random(__UpperCAmelCase)).to(__UpperCAmelCase)
      a						:		List[str]      							=			image.cpu().permute(0				, 2				, 3				, 1)[0]
      a						:		Union[str, Any]      							=			Image.fromarray(np.uinta(__UpperCAmelCase)).convert("RGB").resize((64, 64))
      a						:		Dict      							=			Image.fromarray(np.uinta(image + 4)).convert("RGB").resize((64, 64))
      if str(__UpperCAmelCase).startswith("mps"):
        a						:		Tuple      							=			torch.manual_seed(__UpperCAmelCase)
      else:
        a						:		Tuple      							=			torch.Generator(device=__UpperCAmelCase).manual_seed(__UpperCAmelCase)
      a						:		Optional[Any]      							=			{
          "prompt": "A painting of a squirrel eating a burger",
          "image": init_image,
          "mask_image": mask_image,
          "generator": generator,
          "num_inference_steps": 2,
          "guidance_scale": 6.0,
          "output_type": "numpy",
      }
      return inputs






    def 	__snake_case							(					self				:    List[str]):
      a						:		Union[str, Any]      							=			"cpu"  # ensure determinism for the device-dependent torch.Generator
      a						:		Tuple      							=			self.get_dummy_components()
      a						:		Optional[int]      							=			StableDiffusionInpaintPipeline(**__UpperCAmelCase)
      a						:		int      							=			sd_pipe.to(__UpperCAmelCase)
      sd_pipe.set_progress_bar_config(disable=__UpperCAmelCase)

      a						:		Any      							=			self.get_dummy_inputs(__UpperCAmelCase)
      a						:		Optional[int]      							=			sd_pipe(**__UpperCAmelCase).images
      a						:		Optional[int]      							=			image[0, -3:, -3:, -1]

      assert image.shape == (1, 64, 64, 3)
      a						:		int      							=			np.array([0.4_727, 0.5_735, 0.3_941, 0.5_446, 0.5_926, 0.4_394, 0.5_062, 0.4_654, 0.4_476])

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






    def 	__snake_case							(					self				:    str):
      super().test_inference_batch_single_identical(expected_max_diff=3e-3)






@slow
@require_torch_gpu
class 						_A  (  unittest.TestCase  ):







    """simple docstring"""




    def 	__snake_case							(					self				:    Union[str, Any]):
      # clean up the VRAM after each test
      super().tearDown()
      gc.collect()
      torch.cuda.empty_cache()






    def 	__snake_case							(					self				:    Dict):
      a						:		str      							=			load_image(
          "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
          "/sd2-inpaint/init_image.png")
      a						:		str      							=			load_image(
          "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-inpaint/mask.png")
      a						:		List[Any]      							=			load_numpy(
          "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-inpaint"
          "/yellow_cat_sitting_on_a_park_bench.npy")

      a						:		Tuple      							=			"stabilityai/stable-diffusion-2-inpainting"
      a						:		Optional[Any]      							=			StableDiffusionInpaintPipeline.from_pretrained(__UpperCAmelCase				, safety_checker=__UpperCAmelCase)
      pipe.to(__UpperCAmelCase)
      pipe.set_progress_bar_config(disable=__UpperCAmelCase)
      pipe.enable_attention_slicing()

      a						:		Any      							=			"Face of a yellow cat, high resolution, sitting on a park bench"

      a						:		str      							=			torch.manual_seed(0)
      a						:		Union[str, Any]      							=			pipe(
          prompt=__UpperCAmelCase				, image=__UpperCAmelCase				, mask_image=__UpperCAmelCase				, generator=__UpperCAmelCase				, output_type="np"				, )
      a						:		List[str]      							=			output.images[0]

      assert image.shape == (512, 512, 3)
      assert np.abs(expected_image - image).max() < 9e-3






    def 	__snake_case							(					self				:    Any):
      a						:		str      							=			load_image(
          "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
          "/sd2-inpaint/init_image.png")
      a						:		Optional[Any]      							=			load_image(
          "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-inpaint/mask.png")
      a						:		str      							=			load_numpy(
          "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-inpaint"
          "/yellow_cat_sitting_on_a_park_bench_fp16.npy")

      a						:		Optional[Any]      							=			"stabilityai/stable-diffusion-2-inpainting"
      a						:		Any      							=			StableDiffusionInpaintPipeline.from_pretrained(
          __UpperCAmelCase				, torch_dtype=torch.floataa				, safety_checker=__UpperCAmelCase				, )
      pipe.to(__UpperCAmelCase)
      pipe.set_progress_bar_config(disable=__UpperCAmelCase)
      pipe.enable_attention_slicing()

      a						:		Optional[int]      							=			"Face of a yellow cat, high resolution, sitting on a park bench"

      a						:		Dict      							=			torch.manual_seed(0)
      a						:		List[Any]      							=			pipe(
          prompt=__UpperCAmelCase				, image=__UpperCAmelCase				, mask_image=__UpperCAmelCase				, generator=__UpperCAmelCase				, output_type="np"				, )
      a						:		Optional[Any]      							=			output.images[0]

      assert image.shape == (512, 512, 3)
      assert np.abs(expected_image - image).max() < 5e-1






    def 	__snake_case							(					self				:    int):
      torch.cuda.empty_cache()
      torch.cuda.reset_max_memory_allocated()
      torch.cuda.reset_peak_memory_stats()

      a						:		Tuple      							=			load_image(
          "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
          "/sd2-inpaint/init_image.png")
      a						:		Optional[int]      							=			load_image(
          "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-inpaint/mask.png")

      a						:		Optional[Any]      							=			"stabilityai/stable-diffusion-2-inpainting"
      a						:		Optional[int]      							=			PNDMScheduler.from_pretrained(__UpperCAmelCase				, subfolder="scheduler")
      a						:		int      							=			StableDiffusionInpaintPipeline.from_pretrained(
          __UpperCAmelCase				, safety_checker=__UpperCAmelCase				, scheduler=__UpperCAmelCase				, torch_dtype=torch.floataa				, )
      pipe.to(__UpperCAmelCase)
      pipe.set_progress_bar_config(disable=__UpperCAmelCase)
      pipe.enable_attention_slicing(1)
      pipe.enable_sequential_cpu_offload()

      a						:		Optional[int]      							=			"Face of a yellow cat, high resolution, sitting on a park bench"

      a						:		Optional[int]      							=			torch.manual_seed(0)
      a						:		str      							=			pipe(
          prompt=__UpperCAmelCase				, image=__UpperCAmelCase				, mask_image=__UpperCAmelCase				, generator=__UpperCAmelCase				, num_inference_steps=2				, output_type="np"				, )

      a						:		int      							=			torch.cuda.max_memory_allocated()
      # make sure that less than 2.65 GB is allocated
      assert mem_bytes < 2.65 * 10**9






