from __future__ import annotations

from random import random
from typing import Generic, TypeVar

SCREAMING_SNAKE_CASE__		:       List[str]       						=       TypeVar("KT")
SCREAMING_SNAKE_CASE__		:       str       						=       TypeVar("VT")

class    snake_case       (   Generic[KT, VT]    ):




  def __init__(   self  :						Union[str, Any]  ,			a_  :						KT | str = "root"  ,			a_  :						VT | None = None					)->							Optional[Any]:




       """simple docstring"""
       SCREAMING_SNAKE_CASE__					:					Optional[int]      =		key
       SCREAMING_SNAKE_CASE__					:					Dict      =		value
       SCREAMING_SNAKE_CASE__					:					list[Node[KT, VT]]      =		[]




  def __repr__(   self  :						Dict					)->							str:




       """simple docstring"""
       return F'''Node({self.key}: {self.value})'''




  @property
  def 						__lowercase(   self  :						List[str]					)->							int:




       """simple docstring"""
       return len(self.forward					)




class    snake_case       (   Generic[KT, VT]    ):




  def __init__(   self  :						Union[str, Any]  ,			a_  :						float = 0.5  ,			a_  :						int = 16					)->							List[Any]:




       """simple docstring"""
       SCREAMING_SNAKE_CASE__					:					Node[KT, VT]      =		Node[KT, VT]()
       SCREAMING_SNAKE_CASE__					:					Tuple      =		0
       SCREAMING_SNAKE_CASE__					:					str      =		p
       SCREAMING_SNAKE_CASE__					:					Optional[int]      =		max_level




  def __str__(   self  :						Optional[Any]					)->							str:




       """simple docstring"""
       SCREAMING_SNAKE_CASE__					:					Dict      =		list(self					)

       if len(a_					) == 0:
            return F'''SkipList(level={self.level})'''

       SCREAMING_SNAKE_CASE__					:					str      =		max((len(str(a_					)					) for item in items)  ,			default=4					)
       SCREAMING_SNAKE_CASE__					:					Dict      =		max(a_  ,			4					) + 4

       SCREAMING_SNAKE_CASE__					:					Dict      =		self.head
       SCREAMING_SNAKE_CASE__					:					Union[str, Any]      =		[]

       SCREAMING_SNAKE_CASE__					:					int      =		node.forward.copy()
       lines.append(F'''[{node.key}]'''.ljust(a_  ,			'-'					) + '* ' * len(a_					)					)
       lines.append(' ' * label_size + '| ' * len(a_					)					)

       while len(node.forward					) != 0:
            SCREAMING_SNAKE_CASE__					:					int      =		node.forward[0]

            lines.append(
                F'''[{node.key}]'''.ljust(a_  ,			'-'					)
                + ' '.join(str(n.key					) if n.key == node.key else '|' for n in forwards					)					)
            lines.append(' ' * label_size + '| ' * len(a_					)					)
            SCREAMING_SNAKE_CASE__					:					Optional[int]      =		node.forward

       lines.append('None'.ljust(a_					) + '* ' * len(a_					)					)
       return F'''SkipList(level={self.level})\n''' + "\n".join(a_					)




  def __iter__(   self  :						Optional[int]					)->							Tuple:




       """simple docstring"""
       SCREAMING_SNAKE_CASE__					:					Tuple      =		self.head

       while len(node.forward					) != 0:
            yield node.forward[0].key
            SCREAMING_SNAKE_CASE__					:					Optional[int]      =		node.forward[0]




  def 						__lowercase(   self  :						str					)->							int:




       """simple docstring"""
       SCREAMING_SNAKE_CASE__					:					List[str]      =		1
       while random() < self.p and level < self.max_level:
            level += 1

       return level




  def 						__lowercase(   self  :						Dict  ,			a_  :						Optional[int]					)->							tuple[Node[KT, VT] | None, list[Node[KT, VT]]]:




       """simple docstring"""
       SCREAMING_SNAKE_CASE__					:					int      =		[]

       SCREAMING_SNAKE_CASE__					:					Any      =		self.head

       for i in reversed(range(self.level					)					):
            # i < node.level - When node level is lesser than `i` decrement `i`.
            # node.forward[i].key < key - Jumping to node with key value higher
            #                             or equal to searched key would result
            #                             in skipping searched key.
            while i < node.level and node.forward[i].key < key:
                 SCREAMING_SNAKE_CASE__					:					str      =		node.forward[i]
            # Each leftmost node (relative to searched node) will potentially have to
            # be updated.
            update_vector.append(a_					)

       update_vector.reverse()  # Note that we were inserting values in reverse order.

       # len(node.forward) != 0 - If current node doesn't contain any further
       #                          references then searched key is not present.
       # node.forward[0].key == key - Next node key should be equal to search key
       #                              if key is present.
       if len(node.forward					) != 0 and node.forward[0].key == key:
            return node.forward[0], update_vector
       else:
            return None, update_vector




  def 						__lowercase(   self  :						Optional[Any]  ,			a_  :						KT					)->							Dict:




       """simple docstring"""
       SCREAMING_SNAKE_CASE__      ,				SCREAMING_SNAKE_CASE__					:					Union[str, Any]      =		self._locate_node(a_					)

       if node is not None:
            for i, update_node in enumerate(a_					):
                 # Remove or replace all references to removed node.
                 if update_node.level > i and update_node.forward[i].key == key:
                      if node.level > i:
                           SCREAMING_SNAKE_CASE__					:					List[Any]      =		node.forward[i]
                      else:
                           SCREAMING_SNAKE_CASE__					:					Optional[Any]      =		update_node.forward[:i]




  def 						__lowercase(   self  :						Any  ,			a_  :						KT  ,			a_  :						VT					)->							List[str]:




       """simple docstring"""
       SCREAMING_SNAKE_CASE__      ,				SCREAMING_SNAKE_CASE__					:					str      =		self._locate_node(a_					)
       if node is not None:
            SCREAMING_SNAKE_CASE__					:					str      =		value
       else:
            SCREAMING_SNAKE_CASE__					:					Dict      =		self.random_level()

            if level > self.level:
                 # After level increase we have to add additional nodes to head.
                 for _ in range(self.level - 1  ,			a_					):
                      update_vector.append(self.head					)
                 SCREAMING_SNAKE_CASE__					:					List[Any]      =		level

            SCREAMING_SNAKE_CASE__					:					Union[str, Any]      =		Node(a_  ,			a_					)

            for i, update_node in enumerate(update_vector[:level]					):
                 # Change references to pass through new node.
                 if update_node.level > i:
                      new_node.forward.append(update_node.forward[i]					)

                 if update_node.level < i + 1:
                      update_node.forward.append(a_					)
                 else:
                      SCREAMING_SNAKE_CASE__					:					Optional[int]      =		new_node




  def 						__lowercase(   self  :						Any  ,			a_  :						VT					)->							VT | None:




       """simple docstring"""
       SCREAMING_SNAKE_CASE__      ,				SCREAMING_SNAKE_CASE__					:					int      =		self._locate_node(a_					)

       if node is not None:
            return node.value

       return None







def      _a					(   ):







     '''simple docstring'''


     SCREAMING_SNAKE_CASE__					:					Optional[int]      =		SkipList()
     skip_list.insert('Key1'  ,	3			)
     skip_list.insert('Key2'  ,	12			)
     skip_list.insert('Key3'  ,	41			)
     skip_list.insert('Key4'  ,	-19			)

     SCREAMING_SNAKE_CASE__					:					Tuple      =		skip_list.head
     SCREAMING_SNAKE_CASE__					:					Optional[int]      =		{}
     while node.level != 0:
          SCREAMING_SNAKE_CASE__					:					Union[str, Any]      =		node.forward[0]
          SCREAMING_SNAKE_CASE__					:					Union[str, Any]      =		node.value

     assert len(lowercase__			) == 4
     assert all_values["Key1"] == 3
     assert all_values["Key2"] == 12
     assert all_values["Key3"] == 41
     assert all_values["Key4"] == -19







def      _a					(   ):







     '''simple docstring'''


     SCREAMING_SNAKE_CASE__					:					List[str]      =		SkipList()
     skip_list.insert('Key1'  ,	10			)
     skip_list.insert('Key1'  ,	12			)

     skip_list.insert('Key5'  ,	7			)
     skip_list.insert('Key7'  ,	10			)
     skip_list.insert('Key10'  ,	5			)

     skip_list.insert('Key7'  ,	7			)
     skip_list.insert('Key5'  ,	5			)
     skip_list.insert('Key10'  ,	10			)

     SCREAMING_SNAKE_CASE__					:					Dict      =		skip_list.head
     SCREAMING_SNAKE_CASE__					:					Any      =		{}
     while node.level != 0:
          SCREAMING_SNAKE_CASE__					:					int      =		node.forward[0]
          SCREAMING_SNAKE_CASE__					:					List[Any]      =		node.value

     if len(lowercase__			) != 4:
          print()
     assert len(lowercase__			) == 4
     assert all_values["Key1"] == 12
     assert all_values["Key7"] == 7
     assert all_values["Key5"] == 5
     assert all_values["Key10"] == 10







def      _a					(   ):







     '''simple docstring'''


     SCREAMING_SNAKE_CASE__					:					str      =		SkipList()
     assert skip_list.find('Some key'			) is None







def      _a					(   ):







     '''simple docstring'''


     SCREAMING_SNAKE_CASE__					:					Optional[Any]      =		SkipList()

     skip_list.insert('Key2'  ,	20			)
     assert skip_list.find('Key2'			) == 20

     skip_list.insert('Some Key'  ,	10			)
     skip_list.insert('Key2'  ,	8			)
     skip_list.insert('V'  ,	13			)

     assert skip_list.find('Y'			) is None
     assert skip_list.find('Key2'			) == 8
     assert skip_list.find('Some Key'			) == 10
     assert skip_list.find('V'			) == 13







def      _a					(   ):







     '''simple docstring'''


     SCREAMING_SNAKE_CASE__					:					Any      =		SkipList()
     skip_list.delete('Some key'			)

     assert len(skip_list.head.forward			) == 0







def      _a					(   ):







     '''simple docstring'''


     SCREAMING_SNAKE_CASE__					:					List[Any]      =		SkipList()

     skip_list.insert('Key1'  ,	12			)
     skip_list.insert('V'  ,	13			)
     skip_list.insert('X'  ,	14			)
     skip_list.insert('Key2'  ,	15			)

     skip_list.delete('V'			)
     skip_list.delete('Key2'			)

     assert skip_list.find('V'			) is None
     assert skip_list.find('Key2'			) is None







def      _a					(   ):







     '''simple docstring'''


     SCREAMING_SNAKE_CASE__					:					Dict      =		SkipList()

     skip_list.insert('Key1'  ,	12			)
     skip_list.insert('V'  ,	13			)
     skip_list.insert('X'  ,	14			)
     skip_list.insert('Key2'  ,	15			)

     skip_list.delete('V'			)
     assert skip_list.find('V'			) is None
     assert skip_list.find('X'			) == 14
     assert skip_list.find('Key1'			) == 12
     assert skip_list.find('Key2'			) == 15

     skip_list.delete('X'			)
     assert skip_list.find('V'			) is None
     assert skip_list.find('X'			) is None
     assert skip_list.find('Key1'			) == 12
     assert skip_list.find('Key2'			) == 15

     skip_list.delete('Key1'			)
     assert skip_list.find('V'			) is None
     assert skip_list.find('X'			) is None
     assert skip_list.find('Key1'			) is None
     assert skip_list.find('Key2'			) == 15

     skip_list.delete('Key2'			)
     assert skip_list.find('V'			) is None
     assert skip_list.find('X'			) is None
     assert skip_list.find('Key1'			) is None
     assert skip_list.find('Key2'			) is None







def      _a					(   ):







     '''simple docstring'''


     SCREAMING_SNAKE_CASE__					:					Any      =		SkipList()

     skip_list.insert('Key1'  ,	12			)
     skip_list.insert('V'  ,	13			)
     skip_list.insert('X'  ,	1_42			)
     skip_list.insert('Key2'  ,	15			)

     skip_list.delete('X'			)

     def traverse_keys(lowercase__	:      Any			):
          yield node.key
          for forward_node in node.forward:
               yield from traverse_keys(lowercase__			)

     assert len(set(traverse_keys(skip_list.head			)			)			) == 4







def      _a					(   ):







     '''simple docstring'''


     def is_sorted(lowercase__	:      int			):
          return all(next_item >= item for item, next_item in zip(lowercase__  ,	lst[1:]			)			)

     SCREAMING_SNAKE_CASE__					:					Dict      =		SkipList()
     for i in range(10			):
          skip_list.insert(lowercase__  ,	lowercase__			)
     assert is_sorted(list(lowercase__			)			)
     skip_list.delete(5			)
     skip_list.delete(8			)
     skip_list.delete(2			)
     assert is_sorted(list(lowercase__			)			)
     skip_list.insert(-12  ,	-12			)
     skip_list.insert(77  ,	77			)
     assert is_sorted(list(lowercase__			)			)







def      _a					(   ):







     '''simple docstring'''


     for _ in range(1_00			):
          # Repeat test 100 times due to the probabilistic nature of skip list
          # random values == random bugs
          test_insert()
          test_insert_overrides_existing_value()

          test_searching_empty_list_returns_none()
          test_search()

          test_deleting_item_from_empty_list_do_nothing()
          test_deleted_items_are_not_founded_by_find_method()
          test_delete_removes_only_given_key()
          test_delete_doesnt_leave_dead_nodes()

          test_iter_always_yields_sorted_values()







def      _a					(   ):







     '''simple docstring'''


     SCREAMING_SNAKE_CASE__					:					Optional[Any]      =		SkipList()
     skip_list.insert(2  ,	'2'			)
     skip_list.insert(4  ,	'4'			)
     skip_list.insert(6  ,	'4'			)
     skip_list.insert(4  ,	'5'			)
     skip_list.insert(8  ,	'4'			)
     skip_list.insert(9  ,	'4'			)

     skip_list.delete(4			)

     print(lowercase__			)


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      main()







'''simple docstring'''






import gc
import unittest

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

from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel
from diffusers.pipelines.alt_diffusion.modeling_roberta_series import (
    RobertaSeriesConfig,
    RobertaSeriesModelWithTransformation,
)
from diffusers.utils import slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, 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


enable_full_determinism()




class 						a__							(				a__							,							a__							,							a__							,							unittest.TestCase    ):





							'''simple docstring'''






							lowercase__     :  Optional[Any]      		= AltDiffusionPipeline
							lowercase__     :  Dict      		= TEXT_TO_IMAGE_PARAMS
							lowercase__     :  str      		= TEXT_TO_IMAGE_BATCH_PARAMS
							lowercase__     :  Any      		= TEXT_TO_IMAGE_IMAGE_PARAMS
							lowercase__     :  List[str]      		= TEXT_TO_IMAGE_IMAGE_PARAMS







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				str:
														torch.manual_seed(0  )
														lowerCAmelCase__			  =      UNetaDConditionModel(
														    block_out_channels=(32, 64)   ,       layers_per_block=2   ,       sample_size=32   ,       in_channels=4   ,       out_channels=4   ,       down_block_types=('''DownBlock2D''', '''CrossAttnDownBlock2D''')   ,       up_block_types=('''CrossAttnUpBlock2D''', '''UpBlock2D''')   ,       cross_attention_dim=32   ,       )
														lowerCAmelCase__			  =      DDIMScheduler(
														    beta_start=0.00_085   ,       beta_end=0.012   ,       beta_schedule='''scaled_linear'''   ,       clip_sample=lowerCamelCase_   ,       set_alpha_to_one=lowerCamelCase_   ,       )
														torch.manual_seed(0  )
														lowerCAmelCase__			  =      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   ,       )

														# TODO: address the non-deterministic text encoder (fails for save-load tests)
														# torch.manual_seed(0)
														# text_encoder_config = RobertaSeriesConfig(
														#     hidden_size=32,
														#     project_dim=32,
														#     intermediate_size=37,
														#     layer_norm_eps=1e-05,
														#     num_attention_heads=4,
														#     num_hidden_layers=5,
														#     vocab_size=5002,
														# )
														# text_encoder = RobertaSeriesModelWithTransformation(text_encoder_config)

														torch.manual_seed(0  )
														lowerCAmelCase__			  =      CLIPTextConfig(
														    bos_token_id=0   ,       eos_token_id=2   ,       hidden_size=32   ,       projection_dim=32   ,       intermediate_size=37   ,       layer_norm_eps=1e-05   ,       num_attention_heads=4   ,       num_hidden_layers=5   ,       pad_token_id=1   ,       vocab_size=50_02   ,       )
														lowerCAmelCase__			  =      CLIPTextModel(lowerCamelCase_  )

														lowerCAmelCase__			  =      XLMRobertaTokenizer.from_pretrained('''hf-internal-testing/tiny-xlm-roberta'''  )
														lowerCAmelCase__			  =      77

														lowerCAmelCase__			  =      {
														    '''unet''': unet,
														    '''scheduler''': scheduler,
														    '''vae''': vae,
														    '''text_encoder''': text_encoder,
														    '''tokenizer''': tokenizer,
														    '''safety_checker''': None,
														    '''feature_extractor''': None,
														}
														return components







							def     __SCREAMING_SNAKE_CASE				(						self   ,       lowerCamelCase_   ,       lowerCamelCase_=0  )			->				List[str]:
														if str(lowerCamelCase_  ).startswith('''mps'''  ):
																					lowerCAmelCase__			  =      torch.manual_seed(lowerCamelCase_  )
														else:
																					lowerCAmelCase__			  =      torch.Generator(device=lowerCamelCase_  ).manual_seed(lowerCamelCase_  )
														lowerCAmelCase__			  =      {
														    '''prompt''': '''A painting of a squirrel eating a burger''',
														    '''generator''': generator,
														    '''num_inference_steps''': 2,
														    '''guidance_scale''': 6.0,
														    '''output_type''': '''numpy''',
														}
														return inputs







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				Union[str, Any]:
														super().test_attention_slicing_forward_pass(expected_max_diff=3e-3  )







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				Optional[int]:
														super().test_inference_batch_single_identical(expected_max_diff=3e-3  )







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				List[str]:
														lowerCAmelCase__			  =      '''cpu'''  # ensure determinism for the device-dependent torch.Generator

														lowerCAmelCase__			  =      self.get_dummy_components()
														torch.manual_seed(0  )
														lowerCAmelCase__			  =      RobertaSeriesConfig(
														    hidden_size=32   ,       project_dim=32   ,       intermediate_size=37   ,       layer_norm_eps=1e-05   ,       num_attention_heads=4   ,       num_hidden_layers=5   ,       vocab_size=50_02   ,       )
														# TODO: remove after fixing the non-deterministic text encoder
														lowerCAmelCase__			  =      RobertaSeriesModelWithTransformation(lowerCamelCase_  )
														lowerCAmelCase__			  =      text_encoder

														lowerCAmelCase__			  =      AltDiffusionPipeline(**lowerCamelCase_  )
														lowerCAmelCase__			  =      alt_pipe.to(lowerCamelCase_  )
														alt_pipe.set_progress_bar_config(disable=lowerCamelCase_  )

														lowerCAmelCase__			  =      self.get_dummy_inputs(lowerCamelCase_  )
														lowerCAmelCase__			  =      '''A photo of an astronaut'''
														lowerCAmelCase__			  =      alt_pipe(**lowerCamelCase_  )
														lowerCAmelCase__			  =      output.images
														lowerCAmelCase__			  =      image[0, -3:, -3:, -1]

														assert image.shape == (1, 64, 64, 3)
														lowerCAmelCase__			  =      np.array(
														    [0.5_748_162, 0.60_447_145, 0.48_821_217, 0.50_100_636, 0.5_431_185, 0.45_763_683, 0.49_657_696, 0.48_132_733, 0.47_573_093]  )

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







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				List[Any]:
														lowerCAmelCase__			  =      '''cpu'''  # ensure determinism for the device-dependent torch.Generator

														lowerCAmelCase__			  =      self.get_dummy_components()
														lowerCAmelCase__			  =      PNDMScheduler(skip_prk_steps=lowerCamelCase_  )
														torch.manual_seed(0  )
														lowerCAmelCase__			  =      RobertaSeriesConfig(
														    hidden_size=32   ,       project_dim=32   ,       intermediate_size=37   ,       layer_norm_eps=1e-05   ,       num_attention_heads=4   ,       num_hidden_layers=5   ,       vocab_size=50_02   ,       )
														# TODO: remove after fixing the non-deterministic text encoder
														lowerCAmelCase__			  =      RobertaSeriesModelWithTransformation(lowerCamelCase_  )
														lowerCAmelCase__			  =      text_encoder
														lowerCAmelCase__			  =      AltDiffusionPipeline(**lowerCamelCase_  )
														lowerCAmelCase__			  =      alt_pipe.to(lowerCamelCase_  )
														alt_pipe.set_progress_bar_config(disable=lowerCamelCase_  )

														lowerCAmelCase__			  =      self.get_dummy_inputs(lowerCamelCase_  )
														lowerCAmelCase__			  =      alt_pipe(**lowerCamelCase_  )
														lowerCAmelCase__			  =      output.images
														lowerCAmelCase__			  =      image[0, -3:, -3:, -1]

														assert image.shape == (1, 64, 64, 3)
														lowerCAmelCase__			  =      np.array(
														    [0.51_605_093, 0.5_707_241, 0.47_365_507, 0.50_578_886, 0.5_633_877, 0.4_642_503, 0.5_182_081, 0.48_763_484, 0.49_084_237]  )

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




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





							'''simple docstring'''






							def     __SCREAMING_SNAKE_CASE				(						self  )			->				Tuple:
														# clean up the VRAM after each test
														super().tearDown()
														gc.collect()
														torch.cuda.empty_cache()







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				List[Any]:
														# make sure here that pndm scheduler skips prk
														lowerCAmelCase__			  =      AltDiffusionPipeline.from_pretrained('''BAAI/AltDiffusion'''   ,       safety_checker=lowerCamelCase_  )
														lowerCAmelCase__			  =      alt_pipe.to(lowerCamelCase_  )
														alt_pipe.set_progress_bar_config(disable=lowerCamelCase_  )

														lowerCAmelCase__			  =      '''A painting of a squirrel eating a burger'''
														lowerCAmelCase__			  =      torch.manual_seed(0  )
														lowerCAmelCase__			  =      alt_pipe([prompt]   ,       generator=lowerCamelCase_   ,       guidance_scale=6.0   ,       num_inference_steps=20   ,       output_type='''np'''  )

														lowerCAmelCase__			  =      output.images

														lowerCAmelCase__			  =      image[0, -3:, -3:, -1]

														assert image.shape == (1, 5_12, 5_12, 3)
														lowerCAmelCase__			  =      np.array([0.1_010, 0.0_800, 0.0_794, 0.0_885, 0.0_843, 0.0_762, 0.0_769, 0.0_729, 0.0_586]  )

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







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				Any:
														lowerCAmelCase__			  =      DDIMScheduler.from_pretrained('''BAAI/AltDiffusion'''   ,       subfolder='''scheduler'''  )

														lowerCAmelCase__			  =      AltDiffusionPipeline.from_pretrained('''BAAI/AltDiffusion'''   ,       scheduler=lowerCamelCase_   ,       safety_checker=lowerCamelCase_  )
														lowerCAmelCase__			  =      alt_pipe.to(lowerCamelCase_  )
														alt_pipe.set_progress_bar_config(disable=lowerCamelCase_  )

														lowerCAmelCase__			  =      '''A painting of a squirrel eating a burger'''
														lowerCAmelCase__			  =      torch.manual_seed(0  )

														lowerCAmelCase__			  =      alt_pipe([prompt]   ,       generator=lowerCamelCase_   ,       num_inference_steps=2   ,       output_type='''numpy'''  )
														lowerCAmelCase__			  =      output.images

														lowerCAmelCase__			  =      image[0, -3:, -3:, -1]

														assert image.shape == (1, 5_12, 5_12, 3)
														lowerCAmelCase__			  =      np.array([0.4_019, 0.4_052, 0.3_810, 0.4_119, 0.3_916, 0.3_982, 0.4_651, 0.4_195, 0.5_323]  )

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