

'''simple docstring'''






import collections
import json
import os
import re
from typing import TYPE_CHECKING, List, Optional, Tuple

import numpy as np

from ...tokenization_utils_fast import PreTrainedTokenizer
from ...utils import logging


if TYPE_CHECKING:
 from transformers.pipelines.conversational import Conversation


lowerCAmelCase__											=	logging.get_logger(__name__)

lowerCAmelCase__											=	{'''vocab_file''': '''vocab.txt''', '''emoji_file''': '''emoji.json'''}

lowerCAmelCase__											=	{
    '''vocab_file''': {
        '''abeja/gpt-neox-japanese-2.7b''': '''https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/vocab.txt''',
    },
    '''emoji_file''': {
        '''abeja/gpt-neox-japanese-2.7b''': '''https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/emoji.json''',
    },
}

lowerCAmelCase__											=	{
    '''abeja/gpt-neox-japanese-2.7b''': 2048,
}


def 		_A     (    A__     ,				A__      ):






 """simple docstring"""



 with open(SCREAMING_SNAKE_CASE_     ,				'''r'''     ,				encoding='''utf-8'''      ) as f:
  __lowercase							  = json.loads(f.read()      )

 __lowercase							  = collections.OrderedDict()
 __lowercase							  = collections.OrderedDict()
 __lowercase							  = collections.OrderedDict()
 with open(SCREAMING_SNAKE_CASE_     ,				'''r'''     ,				encoding='''utf-8'''      ) as f:
  __lowercase							  = f.readlines()
 __lowercase							  = [[t.rstrip('''\n'''      )] if (t == ',' or ',' not in t) else t.rstrip('''\n'''      ).split(''','''      ) for t in token]
 for idx, b in enumerate(SCREAMING_SNAKE_CASE_      ):
  __lowercase							  = b
  __lowercase							  = idx
  for wd in b:
   __lowercase							  = idx

 return vocab, raw_vocab, ids_to_tokens, emoji






class 			lowercase_	(lowerCamelCase__      ):




  """simple docstring"""




  SCREAMING_SNAKE_CASE    :  Union[str, Any]							=			VOCAB_FILES_NAMES
  SCREAMING_SNAKE_CASE    :  List[str]							=			PRETRAINED_VOCAB_FILES_MAP
  SCREAMING_SNAKE_CASE    :  int							=			PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
  SCREAMING_SNAKE_CASE    :  Tuple							=			['input_ids', 'attention_mask']






  def __init__(      self   :     Union[str, Any]					,lowercase__   :     Tuple					,lowercase__   :     int					,lowercase__   :     int="<|endoftext|>"					,lowercase__   :     Optional[int]="<|endoftext|>"					,lowercase__   :     List[str]="<|startoftext|>"					,lowercase__   :     Tuple="<|endoftext|>"					,lowercase__   :     Union[str, Any]=False					,**lowercase__   :     int					,):
   super().__init__(
       unk_token=lowercase__					,pad_token=lowercase__					,bos_token=lowercase__					,eos_token=lowercase__					,do_clean_text=lowercase__					,**lowercase__					,)
   if not os.path.isfile(lowercase__			):
    raise ValueError(
        F"Can\'t find a vocabulary file at path \'{vocab_file}\'. To load the vocabulary from a Google pretrained"
        ''' model use `tokenizer = GPTNeoXJapaneseokenizer.from_pretrained(PRETRAINED_MODEL_NAME)`'''			)
   if not os.path.isfile(lowercase__			):
    raise ValueError(
        F"Can\'t find a emoji file at path \'{emoji_file}\'. To load the emoji information from a Google"
        ''' pretrained model use `tokenizer = GPTNeoXJapaneseokenizer.from_pretrained(PRETRAINED_MODEL_NAME)`'''			)
   __lowercase							  = do_clean_text
   __lowercase							  = load_vocab_and_emoji(lowercase__					,lowercase__			)
   __lowercase							  = SubWordJapaneseTokenizer(
       vocab=self.vocab					,ids_to_tokens=self.ids_to_tokens					,emoji=self.emoji			)






  @property
  def 					SCREAMING_SNAKE_CASE      (      self   :     List[str]			):
   return len(self.raw_vocab			)






  def 					SCREAMING_SNAKE_CASE      (      self   :     Tuple			):
   return dict(self.raw_vocab					,**self.added_tokens_encoder			)






  def 					SCREAMING_SNAKE_CASE      (      self   :     Any					,lowercase__   :     str			):
   return self.subword_tokenizer.tokenize(lowercase__					,clean=self.do_clean_text			)






  def 					SCREAMING_SNAKE_CASE      (      self   :     Any					,lowercase__   :     Tuple			):
   return self.vocab.get(lowercase__					,self.vocab.get(self.unk_token			)			)






  def 					SCREAMING_SNAKE_CASE      (      self   :     Tuple					,lowercase__   :     Dict			):
   return self.subword_tokenizer.convert_id_to_token(lowercase__			)






  def 					SCREAMING_SNAKE_CASE      (      self   :     int					,lowercase__   :     List[str]			):
   __lowercase							  = ''.join(lowercase__			).strip()
   return out_string






  def 					SCREAMING_SNAKE_CASE      (      self   :     str					,lowercase__   :     "Conversation"			):
   __lowercase							  = []
   for is_user, text in conversation.iter_texts():
    input_ids.extend(self.encode(lowercase__					,add_special_tokens=lowercase__			) + [self.eos_token_id]			)

   if len(lowercase__			) > self.model_max_length:
    __lowercase							  = input_ids[-self.model_max_length :]
   return input_ids






  def 					SCREAMING_SNAKE_CASE      (      self   :     Dict					,lowercase__   :     str					,lowercase__   :     Optional[str] = None			):
   __lowercase							  = 0
   if os.path.isdir(lowercase__			):
    __lowercase							  = os.path.join(
        lowercase__					,(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''vocab_file''']			)
    __lowercase							  = os.path.join(
        lowercase__					,(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''emoji_file''']			)
   else:
    __lowercase							  = (
        (filename_prefix + '-' if filename_prefix else '') + save_directory + VOCAB_FILES_NAMES['vocab_file']
    )
    __lowercase							  = (
        (filename_prefix + '-' if filename_prefix else '') + save_directory + VOCAB_FILES_NAMES['emoji_file']
    )
   with open(lowercase__					,'''w'''					,encoding='''utf-8'''			) as writer:
    for token_index, token in self.ids_to_tokens.items():
     if index != token_index:
      logger.warning(
          F"Saving vocabulary to {vocab_file}: vocabulary indices are not consecutive."
          ''' Please check that the vocabulary is not corrupted!'''			)
      __lowercase							  = token_index
     writer.write(''','''.join(lowercase__			) + '''\n'''			)
     index += 1
   with open(lowercase__					,'''w'''					,encoding='''utf-8'''			) as writer:
    json.dump(self.emoji					,lowercase__			)
   return vocab_file, emoji_file






class 			lowercase_	(lowerCamelCase__      ):




  """simple docstring"""




  def __init__(      self   :     str					,lowercase__   :     Union[str, Any]					,lowercase__   :     Dict					,lowercase__   :     Optional[int]			):
   __lowercase							  = vocab  # same as swe
   __lowercase							  = ids_to_tokens  # same as bpe
   __lowercase							  = emoji
   __lowercase							  = np.max([len(lowercase__			) for w in self.vocab.keys()]			)
   __lowercase							  = re.compile(r'''(https?|ftp)(:\/\/[-_\.!~*\'()a-zA-Z0-9;\/?:\@&=\+$,%#]+)'''			)
   __lowercase							  = re.compile(r'''[A-Za-z0-9\._+]*@[\-_0-9A-Za-z]+(\.[A-Za-z]+)*'''			)
   __lowercase							  = re.compile(r'''[\(]{0,1}[0-9]{2,4}[\)\-\(]{0,1}[0-9]{2,4}[\)\-]{0,1}[0-9]{3,4}'''			)
   __lowercase							  = re.compile(
       r'''([12]\d{3}[/\-年])*(0?[1-9]|1[0-2])[/\-月]((0?[1-9]|[12][0-9]|3[01])日?)*(\d{1,2}|:|\d{1,2}時|\d{1,2}分|\(日\)|\(月\)|\(火\)|\(水\)|\(木\)|\(金\)|\(土\)|㈰|㈪|㈫|㈬|㈭|㈮|㈯)*'''			)
   __lowercase							  = re.compile(
       r'''(明治|大正|昭和|平成|令和|㍾|㍽|㍼|㍻|\u32ff)\d{1,2}年(0?[1-9]|1[0-2])月(0?[1-9]|[12][0-9]|3[01])日(\d{1,2}|:|\d{1,2}時|\d{1,2}分|\(日\)|\(月\)|\(火\)|\(水\)|\(木\)|\(金\)|\(土\)|㈰|㈪|㈫|㈬|㈭|㈮|㈯)*'''			)
   __lowercase							  = re.compile(
       r'''((0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*億)*((0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*万)*((0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*千)*(0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*(千円|万円|千万円|円|千ドル|万ドル|千万ドル|ドル|千ユーロ|万ユーロ|千万ユーロ|ユーロ)+(\(税込\)|\(税抜\)|\+tax)*'''			)
   __lowercase							  = '─━│┃┄┅┆┇┈┉┊┋┌┍┎┏┐┑┒┓└┕┖┗┘┙┚┛├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋╌╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿'
   __lowercase							  = '▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟'
   __lowercase							  = str.maketrans({k: '''<BLOCK>''' for k in keisen + blocks}			)






  def __len__(      self   :     Optional[int]			):
   return len(self.ids_to_tokens			)






  def 					SCREAMING_SNAKE_CASE      (      self   :     List[str]					,lowercase__   :     List[Any]			):
   __lowercase							  = self.content_repattera.sub('''<URL>'''					,lowercase__			)
   __lowercase							  = self.content_repattera.sub('''<EMAIL>'''					,lowercase__			)
   __lowercase							  = self.content_repattera.sub('''<TEL>'''					,lowercase__			)
   __lowercase							  = self.content_repattera.sub('''<DATE>'''					,lowercase__			)
   __lowercase							  = self.content_repattera.sub('''<DATE>'''					,lowercase__			)
   __lowercase							  = self.content_repattera.sub('''<PRICE>'''					,lowercase__			)
   __lowercase							  = content.translate(self.content_transa			)
   while "<BLOCK><BLOCK>" in content:
    __lowercase							  = content.replace('''<BLOCK><BLOCK>'''					,'''<BLOCK>'''			)
   return content






  def 					SCREAMING_SNAKE_CASE      (      self   :     str					,lowercase__   :     Tuple					,lowercase__   :     Optional[int]=False			):
   __lowercase							  = text.replace(''' '''					,'''<SP>'''			)
   __lowercase							  = text.replace('''　'''					,'''<SP>'''			)
   __lowercase							  = text.replace('''\r\n'''					,'''<BR>'''			)
   __lowercase							  = text.replace('''\n'''					,'''<BR>'''			)
   __lowercase							  = text.replace('''\r'''					,'''<BR>'''			)
   __lowercase							  = text.replace('''\t'''					,'''<TAB>'''			)
   __lowercase							  = text.replace('''—'''					,'''ー'''			)
   __lowercase							  = text.replace('''−'''					,'''ー'''			)
   for k, v in self.emoji["emoji"].items():
    if k in text:
     __lowercase							  = text.replace(lowercase__					,lowercase__			)
   if clean:
    __lowercase							  = self.clean_text(lowercase__			)

   def check_simbol(lowercase__   :     Tuple			):
    __lowercase							  = x.encode()
    if len(lowercase__			) == 1 and len(lowercase__			) == 2:
     __lowercase							  = (int(e[0]			) << 8) + int(e[1]			)
     if (
         (c >= 0xc_2a1 and c <= 0xc_2bf)
         or (c >= 0xc_780 and c <= 0xc_783)
         or (c >= 0xc_ab9 and c <= 0xc_bbf)
         or (c >= 0xc_c80 and c <= 0xc_da2)
     ):
      return True
    return False

   def checkuae(lowercase__   :     Optional[Any]			):
    __lowercase							  = x.encode()
    if len(lowercase__			) == 1 and len(lowercase__			) == 3:
     __lowercase							  = (int(e[0]			) << 1_6) + (int(e[1]			) << 8) + int(e[2]			)
     if c >= 0xe28_080 and c <= 0xe2b_07f:
      return True
    return False

   __lowercase							  = 0
   __lowercase							  = []
   while pos < len(lowercase__			):
    __lowercase							  = min(len(lowercase__			)					,pos + self.maxlen + 1			) if text[pos] == '<' else pos + 3
    __lowercase							  = []  # (token_id, token, pos)
    for e in range(lowercase__					,lowercase__					,-1			):
     __lowercase							  = text[pos:e]
     if wd in self.vocab:
      if wd[0] == "<" and len(lowercase__			) > 2:
       __lowercase							  = [(self.vocab[wd], wd, e)]
       break
      else:
       candidates.append((self.vocab[wd], wd, e)			)
    if len(lowercase__			) > 0:
     # the smallest token_id is adopted
     __lowercase							  = sorted(lowercase__					,key=lambda lowercase__			: x[0]			)[0]
     result.append(lowercase__			)
     __lowercase							  = e
    else:
     __lowercase							  = pos + 1
     __lowercase							  = text[pos:end]
     if check_simbol(lowercase__			):
      result.append('''<KIGOU>'''			)
     elif checkuae(lowercase__			):
      result.append('''<U2000U2BFF>'''			)
     else:
      for i in wd.encode('''utf-8'''			):
       result.append('''<|byte%d|>''' % i			)
     __lowercase							  = end
   return result






  def 					SCREAMING_SNAKE_CASE      (      self   :     List[str]					,lowercase__   :     Dict					,lowercase__   :     Optional[Any]="\n"			):
   __lowercase							  = []
   __lowercase							  = []
   __lowercase							  = self.ids_to_tokens[index][0]
   if word[:6] == "<|byte" and word[-2:] == "|>":
    byte_tokens.append(int(word[6:-2]			)			)
   else:
    if len(lowercase__			) > 0:
     words.append(bytearray(lowercase__			).decode('''utf-8'''					,errors='''replace'''			)			)
     __lowercase							  = []
    if word[:7] == "<|emoji" and word[-2:] == "|>":
     words.append(self.emoji['''emoji_inv'''][word]			)
    elif word == "<SP>":
     words.append(''' '''			)
    elif word == "<BR>":
     words.append(lowercase__			)
    elif word == "<TAB>":
     words.append('''\t'''			)
    elif word == "<BLOCK>":
     words.append('''▀'''			)
    elif word == "<KIGOU>":
     words.append('''ǀ'''			)
    elif word == "<U2000U2BFF>":
     words.append('''‖'''			)
    else:
     words.append(lowercase__			)
   if len(lowercase__			) > 0:
    words.append(bytearray(lowercase__			).decode('''utf-8'''					,errors='''replace'''			)			)
   __lowercase							  = ''.join(lowercase__			)
   return text



import gc
import unittest

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

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    StableDiffusionAttendAndExcitePipeline,
    UNetaDConditionModel,
)
from diffusers.utils import load_numpy, skip_mps, slow
from diffusers.utils.testing_utils import require_torch_gpu

from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_IMAGE_PARAMS, TEXT_TO_IMAGE_PARAMS
from ..test_pipelines_common import PipelineKarrasSchedulerTesterMixin, PipelineLatentTesterMixin, PipelineTesterMixin


lowerCamelCase__          =		False







@skip_mps
class      A__							(     __magic_name__						,   __magic_name__						,   __magic_name__						,   unittest.TestCase	):
				lowercase			    =  StableDiffusionAttendAndExcitePipeline
				lowercase			    =  False
				lowercase			    =  TEXT_TO_IMAGE_PARAMS
				lowercase			    =  TEXT_TO_IMAGE_BATCH_PARAMS.union({'token_indices'}	)
				lowercase			    =  TEXT_TO_IMAGE_IMAGE_PARAMS
				lowercase			    =  TEXT_TO_IMAGE_IMAGE_PARAMS






				@classmethod
				def 							_lowerCamelCase		(						cls					:      Tuple   ):






							'''simple docstring'''







							super().setUpClass()
							torch.use_deterministic_algorithms(a   )






				@classmethod
				def 							_lowerCamelCase		(						cls					:      Any   ):






							'''simple docstring'''







							super().tearDownClass()
							torch.use_deterministic_algorithms(a   )






				def 							_lowerCamelCase		(						self					:      Optional[Any]   ):






							'''simple docstring'''







							torch.manual_seed(0   )
							lowerCAmelCase__      :      Any         =		UNetaDConditionModel(
							    block_out_channels=(32, 64)    ,     layers_per_block=1    ,     sample_size=32    ,     in_channels=4    ,     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=a    ,     )
							lowerCAmelCase__      :      Any         =		DDIMScheduler(
							    beta_start=0.0_0_0_8_5    ,     beta_end=0.0_1_2    ,     beta_schedule='scaled_linear'    ,     clip_sample=a    ,     set_alpha_to_one=a    ,     )
							torch.manual_seed(0   )
							lowerCAmelCase__      :      Union[str, Any]         =		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   )
							lowerCAmelCase__      :      Tuple         =		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=1_000    ,     hidden_act='gelu'    ,     projection_dim=512    ,     )
							lowerCAmelCase__      :      str         =		CLIPTextModel(a   )
							lowerCAmelCase__      :      Optional[Any]         =		CLIPTokenizer.from_pretrained('hf-internal-testing/tiny-random-clip'   )

							lowerCAmelCase__      :      Union[str, Any]         =		{
							    'unet': unet,
							    'scheduler': scheduler,
							    'vae': vae,
							    'text_encoder': text_encoder,
							    'tokenizer': tokenizer,
							    'safety_checker': None,
							    'feature_extractor': None,
							}

							return components






				def 							_lowerCamelCase		(						self					:      Union[str, Any]    ,     a					:      Tuple    ,     a					:      Union[str, Any]=0   ):






							'''simple docstring'''







							if str(a   ).startswith('mps'   ):
										lowerCAmelCase__      :      List[str]         =		torch.manual_seed(a   )
							else:
										lowerCAmelCase__      :      Any         =		torch.Generator(device=a   ).manual_seed(a   )
							lowerCAmelCase__      :      Optional[int]         =		{
							    'prompt': 'a cat and a frog',
							    'token_indices': [2, 5],
							    'generator': generator,
							    'num_inference_steps': 1,
							    'guidance_scale': 6.0,
							    'output_type': 'numpy',
							    'max_iter_to_alter': 2,
							    'thresholds': {0: 0.7},
							}
							return inputs






				def 							_lowerCamelCase		(						self					:      Optional[int]   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Tuple         =		'cpu'

							lowerCAmelCase__      :      Optional[int]         =		self.get_dummy_components()
							lowerCAmelCase__      :      Dict         =		self.pipeline_class(**a   )
							pipe.to(a   )
							pipe.set_progress_bar_config(disable=a   )

							lowerCAmelCase__      :      Union[str, Any]         =		self.get_dummy_inputs(a   )
							lowerCAmelCase__      :      Union[str, Any]         =		pipe(**a   ).images
							lowerCAmelCase__      :      Optional[int]         =		image[0, -3:, -3:, -1]

							self.assertEqual(image.shape    ,     (1, 64, 64, 3)   )
							lowerCAmelCase__      :      Dict         =		np.array(
							    [0.6_3_9_0_5_3_6_4, 0.6_2_8_9_7_3_0_7, 0.4_8_5_9_9_0_1_7, 0.5_1_3_3_6_2_4, 0.5_5_5_0_0_4_8, 0.4_5_7_6_9_5_1_6, 0.5_0_3_2_6_9_7_3, 0.5_0_2_3_1_3_9, 0.4_5_3_8_4_4_9_6]   )
							lowerCAmelCase__      :      Optional[int]         =		np.abs(image_slice.flatten() - expected_slice   ).max()
							self.assertLessEqual(a    ,     1E-3   )






				def 							_lowerCamelCase		(						self					:      Optional[Any]   ):






							'''simple docstring'''







							super().test_cpu_offload_forward_pass(expected_max_diff=5E-4   )






				def 							_lowerCamelCase		(						self					:      List[str]   ):






							'''simple docstring'''







							self._test_inference_batch_consistent(batch_sizes=[1, 2]   )






				def 							_lowerCamelCase		(						self					:      Tuple   ):






							'''simple docstring'''







							self._test_inference_batch_single_identical(batch_size=2    ,     expected_max_diff=7E-4   )






				def 							_lowerCamelCase		(						self					:      List[Any]   ):






							'''simple docstring'''







							super().test_dict_tuple_outputs_equivalent(expected_max_difference=3E-3   )






				def 							_lowerCamelCase		(						self					:      List[str]   ):






							'''simple docstring'''







							super().test_pt_np_pil_outputs_equivalent(expected_max_diff=5E-4   )






				def 							_lowerCamelCase		(						self					:      Any   ):






							'''simple docstring'''







							super().test_save_load_local(expected_max_difference=5E-4   )






				def 							_lowerCamelCase		(						self					:      Dict   ):






							'''simple docstring'''







							super().test_save_load_optional_components(expected_max_difference=4E-4   )







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






				@classmethod
				def 							_lowerCamelCase		(						cls					:      List[str]   ):






							'''simple docstring'''







							super().setUpClass()
							torch.use_deterministic_algorithms(a   )






				@classmethod
				def 							_lowerCamelCase		(						cls					:      List[str]   ):






							'''simple docstring'''







							super().tearDownClass()
							torch.use_deterministic_algorithms(a   )






				def 							_lowerCamelCase		(						self					:      int   ):






							'''simple docstring'''







							super().tearDown()
							gc.collect()
							torch.cuda.empty_cache()






				def 							_lowerCamelCase		(						self					:      Tuple   ):






							'''simple docstring'''







							lowerCAmelCase__      :      List[str]         =		torch.manual_seed(51   )

							lowerCAmelCase__      :      Any         =		StableDiffusionAttendAndExcitePipeline.from_pretrained(
							    'CompVis/stable-diffusion-v1-4'    ,     safety_checker=a    ,     torch_dtype=torch.floataa   )
							pipe.to('cuda'   )

							lowerCAmelCase__      :      Optional[int]         =		'a painting of an elephant with glasses'
							lowerCAmelCase__      :      Any         =		[5, 7]

							lowerCAmelCase__      :      Optional[Any]         =		pipe(
							    prompt=a    ,     token_indices=a    ,     guidance_scale=7.5    ,     generator=a    ,     num_inference_steps=5    ,     max_iter_to_alter=5    ,     output_type='numpy'    ,     ).images[0]

							lowerCAmelCase__      :      str         =		load_numpy(
							    'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/attend-and-excite/elephant_glasses.npy'   )
							assert np.abs((expected_image - image).max()   ) < 5E-1