


'''simple docstring'''





import dataclasses
import json
import sys
import types
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError
from copy import copy
from enum import Enum
from inspect import isclass
from pathlib import Path
from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Optional, Tuple, Union, get_type_hints

import yaml


__lowerCamelCase												=						NewType('''DataClass''', Any)
__lowerCamelCase												=						NewType('''DataClassType''', Any)


def        a__     (					UpperCamelCase_						:      Tuple						):
   if isinstance(UpperCamelCase_,   UpperCamelCase_						):
      return v
   if v.lower() in ("yes", "true", "t", "y", "1"):
      return True
   elif v.lower() in ("no", "false", "f", "n", "0"):
      return False
   else:
      raise ArgumentTypeError(
          F'''Truthy value expected: got {v} but expected one of yes/no, true/false, t/f, y/n, 1/0 (case insensitive).'''						)


def        a__     (					UpperCamelCase_						:      list						):
   UpperCAmelCase__	:Optional[int]      =      {str(UpperCamelCase_						): choice for choice in choices}
   return lambda UpperCamelCase_						: str_to_choice.get(UpperCamelCase_,   UpperCamelCase_						)


def        a__     (					*,
    UpperCamelCase_						:      Union[str, List[str]] = None,   UpperCamelCase_						:      str = None,   UpperCamelCase_						:      Any = dataclasses.MISSING,   UpperCamelCase_						:      Callable[[], Any] = dataclasses.MISSING,   UpperCamelCase_						:      dict = None,   **UpperCamelCase_						:      str,   ):
   if metadata is None:
      # Important, don't use as default param in function signature because dict is mutable and shared across function calls
      UpperCAmelCase__	:Union[str, Any]      =      {}
   if aliases is not None:
      UpperCAmelCase__	:int      =      aliases
   if help is not None:
      UpperCAmelCase__	:Dict      =      help

   return dataclasses.field(metadata=UpperCamelCase_,   default=UpperCamelCase_,   default_factory=UpperCamelCase_,   **UpperCamelCase_						)




class 				UpperCAmelCase			(			_snake_case						):
 UpperCAmelCase				=					42


 def __init__(      self							:	Dict			,       __lowerCamelCase							:	Union[DataClassType, Iterable[DataClassType]]			,       **__lowerCamelCase							:	int ):
    # To make the default appear when using --help
    if "formatter_class" not in kwargs:
       UpperCAmelCase__	:Tuple      =      ArgumentDefaultsHelpFormatter
    super().__init__(**__lowerCamelCase )
    if dataclasses.is_dataclass(__lowerCamelCase ):
       UpperCAmelCase__	:Optional[Any]      =      [dataclass_types]
    UpperCAmelCase__	:int      =      list(__lowerCamelCase )
    for dtype in self.dataclass_types:
       self._add_dataclass_arguments(__lowerCamelCase )


 @staticmethod
 def        __SCREAMING_SNAKE_CASE					(      __lowerCamelCase							:	ArgumentParser			,       __lowerCamelCase							:	dataclasses.Field ):
    UpperCAmelCase__	:Optional[int]      =      f'''--{field.name}'''
    UpperCAmelCase__	:List[str]      =      field.metadata.copy()
    # field.metadata is not used at all by Data Classes,
    # it is provided as a third-party extension mechanism.
    if isinstance(field.type			,       __lowerCamelCase ):
       raise RuntimeError(
           '''Unresolved type detected, which should have been done with the help of '''
           '''`typing.get_type_hints` method by default''' )

    UpperCAmelCase__	:Tuple      =      kwargs.pop('''aliases'''			,       [] )
    if isinstance(__lowerCamelCase			,       __lowerCamelCase ):
       UpperCAmelCase__	:Union[str, Any]      =      [aliases]

    UpperCAmelCase__	:Tuple      =      getattr(field.type			,       '''__origin__'''			,       field.type )
    if origin_type is Union or (hasattr(__lowerCamelCase			,       '''UnionType''' ) and isinstance(__lowerCamelCase			,       types.UnionType )):
       if str not in field.type.__args__ and (
           len(field.type.__args__ ) != 2 or type(__lowerCamelCase ) not in field.type.__args__
       ):
          raise ValueError(
              '''Only `Union[X, NoneType]` (i.e., `Optional[X]`) is allowed for `Union` because'''
              ''' the argument parser only supports one type per argument.'''
              f''' Problem encountered in field \'{field.name}\'.''' )
       if type(__lowerCamelCase ) not in field.type.__args__:
          # filter `str` in Union
          UpperCAmelCase__	:List[Any]      =      field.type.__args__[0] if field.type.__args__[1] == str else field.type.__args__[1]
          UpperCAmelCase__	:str      =      getattr(field.type			,       '''__origin__'''			,       field.type )
       elif bool not in field.type.__args__:
          # filter `NoneType` in Union (except for `Union[bool, NoneType]`)
          UpperCAmelCase__	:int      =      (
              field.type.__args__[0] if isinstance(__lowerCamelCase			,       field.type.__args__[1] ) else field.type.__args__[1]
          )
          UpperCAmelCase__	:Tuple      =      getattr(field.type			,       '''__origin__'''			,       field.type )

        # A variable to store kwargs for a boolean field, if needed
        # so that we can init a `no_*` complement argument (see below)
    UpperCAmelCase__	:Tuple      =      {}
    if origin_type is Literal or (isinstance(field.type			,       __lowerCamelCase ) and issubclass(field.type			,       __lowerCamelCase )):
       if origin_type is Literal:
          UpperCAmelCase__	:int      =      field.type.__args__
       else:
          UpperCAmelCase__	:Optional[Any]      =      [x.value for x in field.type]

       UpperCAmelCase__	:Tuple      =      make_choice_type_function(kwargs['''choices'''] )

       if field.default is not dataclasses.MISSING:
          UpperCAmelCase__	:Tuple      =      field.default
       else:
          UpperCAmelCase__	:Dict      =      True
    elif field.type is bool or field.type == Optional[bool]:
       # Copy the currect kwargs to use to instantiate a `no_*` complement argument below.
       # We do not initialize it here because the `no_*` alternative must be instantiated after the real argument
       UpperCAmelCase__	:Dict      =      copy(__lowerCamelCase )

       # Hack because type=bool in argparse does not behave as we want.
       UpperCAmelCase__	:Dict      =      string_to_bool
       if field.type is bool or (field.default is not None and field.default is not dataclasses.MISSING):
          # Default value is False if we have no default when of type bool.
          UpperCAmelCase__	:List[str]      =      False if field.default is dataclasses.MISSING else field.default
          # This is the value that will get picked if we don't include --field_name in any way
          UpperCAmelCase__	:int      =      default
          # This tells argparse we accept 0 or 1 value after --field_name
          UpperCAmelCase__	:Any      =      '''?'''
          # This is the value that will get picked if we do --field_name (without value)
          UpperCAmelCase__	:Tuple      =      True
    elif isclass(__lowerCamelCase ) and issubclass(__lowerCamelCase			,       __lowerCamelCase ):
       UpperCAmelCase__	:str      =      field.type.__args__[0]
       UpperCAmelCase__	:Dict      =      '''+'''
       if field.default_factory is not dataclasses.MISSING:
          UpperCAmelCase__	:Dict      =      field.default_factory()
       elif field.default is dataclasses.MISSING:
          UpperCAmelCase__	:str      =      True
    else:
       UpperCAmelCase__	:int      =      field.type
       if field.default is not dataclasses.MISSING:
          UpperCAmelCase__	:Tuple      =      field.default
       elif field.default_factory is not dataclasses.MISSING:
          UpperCAmelCase__	:Optional[Any]      =      field.default_factory()
       else:
          UpperCAmelCase__	:Tuple      =      True
    parser.add_argument(__lowerCamelCase			,       *__lowerCamelCase			,       **__lowerCamelCase )

    # Add a complement `no_*` argument for a boolean field AFTER the initial field has already been added.
    # Order is important for arguments with the same destination!
    # We use a copy of earlier kwargs because the original kwargs have changed a lot before reaching down
    # here and we do not need those changes/additional keys.
    if field.default is True and (field.type is bool or field.type == Optional[bool]):
       UpperCAmelCase__	:Any      =      False
       parser.add_argument(f'''--no_{field.name}'''			,       action='''store_false'''			,       dest=field.name			,       **__lowerCamelCase )


 def        __SCREAMING_SNAKE_CASE					(      self							:	Tuple			,       __lowerCamelCase							:	DataClassType ):
    if hasattr(__lowerCamelCase			,       '''_argument_group_name''' ):
       UpperCAmelCase__	:List[str]      =      self.add_argument_group(dtype._argument_group_name )
    else:
       UpperCAmelCase__	:str      =      self

    try:
       UpperCAmelCase__	:Dict[str, type]      =      get_type_hints(__lowerCamelCase )
    except NameError:
       raise RuntimeError(
           f'''Type resolution failed for {dtype}. Try declaring the class in global scope or '''
           '''removing line of `from __future__ import annotations` which opts in Postponed '''
           '''Evaluation of Annotations (PEP 563)''' )
    except TypeError as ex:
       # Remove this block when we drop Python 3.9 support
       if sys.version_info[:2] < (3, 1_0) and "unsupported operand type(s) for |" in str(__lowerCamelCase ):
          UpperCAmelCase__	:Any      =      '''.'''.join(map(__lowerCamelCase			,       sys.version_info[:3] ) )
          raise RuntimeError(
              f'''Type resolution failed for {dtype} on Python {python_version}. Try removing '''
              '''line of `from __future__ import annotations` which opts in union types as '''
              '''`X | Y` (PEP 604) via Postponed Evaluation of Annotations (PEP 563). To '''
              '''support Python versions that lower than 3.10, you need to use '''
              '''`typing.Union[X, Y]` instead of `X | Y` and `typing.Optional[X]` instead of '''
              '''`X | None`.''' ) from ex
       raise

    for field in dataclasses.fields(__lowerCamelCase ):
       if not field.init:
          continue
       UpperCAmelCase__	:List[str]      =      type_hints[field.name]
       self._parse_dataclass_field(__lowerCamelCase			,       __lowerCamelCase )


 def        __SCREAMING_SNAKE_CASE					(      self							:	Union[str, Any]			,       __lowerCamelCase							:	List[Any]=None			,       __lowerCamelCase							:	Optional[int]=False			,       __lowerCamelCase							:	Any=True			,       __lowerCamelCase							:	Dict=None			,       __lowerCamelCase							:	int=None			,       ):

    if args_file_flag or args_filename or (look_for_args_file and len(sys.argv )):
       UpperCAmelCase__	:Any      =      []

       if args_filename:
          args_files.append(Path(__lowerCamelCase ) )
       elif look_for_args_file and len(sys.argv ):
          args_files.append(Path(sys.argv[0] ).with_suffix('''.args''' ) )

       # args files specified via command line flag should overwrite default args files so we add them last
       if args_file_flag:
          # Create special parser just to extract the args_file_flag values
          UpperCAmelCase__	:Optional[Any]      =      ArgumentParser()
          args_file_parser.add_argument(__lowerCamelCase			,       type=__lowerCamelCase			,       action='''append''' )

          # Use only remaining args for further parsing (remove the args_file_flag)
          UpperCAmelCase__   ,						UpperCAmelCase__	:str      =      args_file_parser.parse_known_args(args=__lowerCamelCase )
          UpperCAmelCase__	:Union[str, Any]      =      vars(__lowerCamelCase ).get(args_file_flag.lstrip('''-''' )			,       __lowerCamelCase )

          if cmd_args_file_paths:
             args_files.extend([Path(__lowerCamelCase ) for p in cmd_args_file_paths] )

       UpperCAmelCase__	:Dict      =      []
       for args_file in args_files:
          if args_file.exists():
             file_args += args_file.read_text().split()

            # in case of duplicate arguments the last one has precedence
            # args specified via the command line should overwrite args from files, so we add them last
       UpperCAmelCase__	:List[str]      =      file_args + args if args is not None else file_args + sys.argv[1:]
    UpperCAmelCase__   ,						UpperCAmelCase__	:List[Any]      =      self.parse_known_args(args=__lowerCamelCase )
    UpperCAmelCase__	:Dict      =      []
    for dtype in self.dataclass_types:
       UpperCAmelCase__	:int      =      {f.name for f in dataclasses.fields(__lowerCamelCase ) if f.init}
       UpperCAmelCase__	:Union[str, Any]      =      {k: v for k, v in vars(__lowerCamelCase ).items() if k in keys}
       for k in keys:
          delattr(__lowerCamelCase			,       __lowerCamelCase )
       UpperCAmelCase__	:str      =      dtype(**__lowerCamelCase )
       outputs.append(__lowerCamelCase )
    if len(namespace.__dict__ ) > 0:
       # additional namespace.
       outputs.append(__lowerCamelCase )
    if return_remaining_strings:
       return (*outputs, remaining_args)
    else:
       if remaining_args:
          raise ValueError(f'''Some specified arguments are not used by the HfArgumentParser: {remaining_args}''' )

       return (*outputs,)


 def        __SCREAMING_SNAKE_CASE					(      self							:	str			,       __lowerCamelCase							:	Dict[str, Any]			,       __lowerCamelCase							:	bool = False ):
    UpperCAmelCase__	:Tuple      =      set(args.keys() )
    UpperCAmelCase__	:Tuple      =      []
    for dtype in self.dataclass_types:
       UpperCAmelCase__	:Tuple      =      {f.name for f in dataclasses.fields(__lowerCamelCase ) if f.init}
       UpperCAmelCase__	:Optional[int]      =      {k: v for k, v in args.items() if k in keys}
       unused_keys.difference_update(inputs.keys() )
       UpperCAmelCase__	:Union[str, Any]      =      dtype(**__lowerCamelCase )
       outputs.append(__lowerCamelCase )
    if not allow_extra_keys and unused_keys:
       raise ValueError(f'''Some keys are not used by the HfArgumentParser: {sorted(__lowerCamelCase )}''' )
    return tuple(__lowerCamelCase )


 def        __SCREAMING_SNAKE_CASE					(      self							:	Tuple			,       __lowerCamelCase							:	str			,       __lowerCamelCase							:	bool = False ):
    with open(Path(__lowerCamelCase )			,       encoding='''utf-8''' ) as open_json_file:
       UpperCAmelCase__	:Tuple      =      json.loads(open_json_file.read() )
    UpperCAmelCase__	:Union[str, Any]      =      self.parse_dict(__lowerCamelCase			,       allow_extra_keys=__lowerCamelCase )
    return tuple(__lowerCamelCase )





 def        __SCREAMING_SNAKE_CASE					(      self							:	Optional[int]			,       __lowerCamelCase							:	str			,       __lowerCamelCase							:	bool = False ):
    UpperCAmelCase__	:Any      =      self.parse_dict(yaml.safe_load(Path(__lowerCamelCase ).read_text() )			,       allow_extra_keys=__lowerCamelCase )
    return tuple(__lowerCamelCase )







'''simple docstring'''





import gc
import unittest

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

from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel
from diffusers.pipelines.vq_diffusion.pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings
from diffusers.utils import load_numpy, slow, torch_device
from diffusers.utils.testing_utils import require_torch_gpu


__lowerCamelCase												=						False




class 				UpperCAmelCase			(			unittest.TestCase						):


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


 @property
 def        __SCREAMING_SNAKE_CASE					(      self							:	str ):
    return 1_2


 @property
 def        __SCREAMING_SNAKE_CASE					(      self							:	List[Any] ):
    return 1_2


 @property
 def        __SCREAMING_SNAKE_CASE					(      self							:	Optional[int] ):
    return 3_2


 @property
 def        __SCREAMING_SNAKE_CASE					(      self							:	List[str] ):
    torch.manual_seed(0 )
    UpperCAmelCase__	:List[str]      =      VQModel(
        block_out_channels=[3_2, 6_4]			,       in_channels=3			,       out_channels=3			,       down_block_types=['''DownEncoderBlock2D''', '''DownEncoderBlock2D''']			,       up_block_types=['''UpDecoderBlock2D''', '''UpDecoderBlock2D''']			,       latent_channels=3			,       num_vq_embeddings=self.num_embed			,       vq_embed_dim=3			,       )
    return model


 @property
 def        __SCREAMING_SNAKE_CASE					(      self							:	int ):
    UpperCAmelCase__	:Tuple      =      CLIPTokenizer.from_pretrained('''hf-internal-testing/tiny-random-clip''' )
    return tokenizer


 @property
 def        __SCREAMING_SNAKE_CASE					(      self							:	Tuple ):
    torch.manual_seed(0 )
    UpperCAmelCase__	:Optional[Any]      =      CLIPTextConfig(
        bos_token_id=0			,       eos_token_id=2			,       hidden_size=self.text_embedder_hidden_size			,       intermediate_size=3_7			,       layer_norm_eps=1e-05			,       num_attention_heads=4			,       num_hidden_layers=5			,       pad_token_id=1			,       vocab_size=1_0_0_0			,       )
    return CLIPTextModel(__lowerCamelCase )


 @property
 def        __SCREAMING_SNAKE_CASE					(      self							:	List[str] ):
    torch.manual_seed(0 )

    UpperCAmelCase__	:List[str]      =      1_2
    UpperCAmelCase__	:Optional[int]      =      1_2

    UpperCAmelCase__	:Optional[int]      =      {
        '''attention_bias''': True,
        '''cross_attention_dim''': 3_2,
        '''attention_head_dim''': height * width,
        '''num_attention_heads''': 1,
        '''num_vector_embeds''': self.num_embed,
        '''num_embeds_ada_norm''': self.num_embeds_ada_norm,
        '''norm_num_groups''': 3_2,
        '''sample_size''': width,
        '''activation_fn''': '''geglu-approximate''',
    }

    UpperCAmelCase__	:List[str]      =      TransformeraDModel(**__lowerCamelCase )
    return model


 def        __SCREAMING_SNAKE_CASE					(      self							:	List[Any] ):
    UpperCAmelCase__	:Union[str, Any]      =      '''cpu'''

    UpperCAmelCase__	:Optional[Any]      =      self.dummy_vqvae
    UpperCAmelCase__	:Optional[int]      =      self.dummy_text_encoder
    UpperCAmelCase__	:Union[str, Any]      =      self.dummy_tokenizer
    UpperCAmelCase__	:List[Any]      =      self.dummy_transformer
    UpperCAmelCase__	:str      =      VQDiffusionScheduler(self.num_embed )
    UpperCAmelCase__	:Optional[Any]      =      LearnedClassifierFreeSamplingEmbeddings(learnable=__lowerCamelCase )

    UpperCAmelCase__	:Any      =      VQDiffusionPipeline(
        vqvae=__lowerCamelCase			,       text_encoder=__lowerCamelCase			,       tokenizer=__lowerCamelCase			,       transformer=__lowerCamelCase			,       scheduler=__lowerCamelCase			,       learned_classifier_free_sampling_embeddings=__lowerCamelCase			,       )
    UpperCAmelCase__	:Any      =      pipe.to(__lowerCamelCase )
    pipe.set_progress_bar_config(disable=__lowerCamelCase )

    UpperCAmelCase__	:str      =      '''teddy bear playing in the pool'''

    UpperCAmelCase__	:Optional[int]      =      torch.Generator(device=__lowerCamelCase ).manual_seed(0 )
    UpperCAmelCase__	:Any      =      pipe([prompt]			,       generator=__lowerCamelCase			,       num_inference_steps=2			,       output_type='''np''' )
    UpperCAmelCase__	:str      =      output.images

    UpperCAmelCase__	:List[Any]      =      torch.Generator(device=__lowerCamelCase ).manual_seed(0 )
    UpperCAmelCase__	:Dict      =      pipe(
        [prompt]			,       generator=__lowerCamelCase			,       output_type='''np'''			,       return_dict=__lowerCamelCase			,       num_inference_steps=2 )[0]

    UpperCAmelCase__	:int      =      image[0, -3:, -3:, -1]
    UpperCAmelCase__	:List[Any]      =      image_from_tuple[0, -3:, -3:, -1]

    assert image.shape == (1, 2_4, 2_4, 3)

    UpperCAmelCase__	:int      =      np.array([0.65_51, 0.61_68, 0.50_08, 0.56_76, 0.56_59, 0.42_95, 0.60_73, 0.55_99, 0.49_92] )

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





 def        __SCREAMING_SNAKE_CASE					(      self							:	Tuple ):
    UpperCAmelCase__	:List[Any]      =      '''cpu'''

    UpperCAmelCase__	:int      =      self.dummy_vqvae
    UpperCAmelCase__	:List[str]      =      self.dummy_text_encoder
    UpperCAmelCase__	:Union[str, Any]      =      self.dummy_tokenizer
    UpperCAmelCase__	:Optional[Any]      =      self.dummy_transformer
    UpperCAmelCase__	:List[str]      =      VQDiffusionScheduler(self.num_embed )
    UpperCAmelCase__	:List[str]      =      LearnedClassifierFreeSamplingEmbeddings(
        learnable=__lowerCamelCase			,       hidden_size=self.text_embedder_hidden_size			,       length=tokenizer.model_max_length )

    UpperCAmelCase__	:List[Any]      =      VQDiffusionPipeline(
        vqvae=__lowerCamelCase			,       text_encoder=__lowerCamelCase			,       tokenizer=__lowerCamelCase			,       transformer=__lowerCamelCase			,       scheduler=__lowerCamelCase			,       learned_classifier_free_sampling_embeddings=__lowerCamelCase			,       )
    UpperCAmelCase__	:str      =      pipe.to(__lowerCamelCase )
    pipe.set_progress_bar_config(disable=__lowerCamelCase )

    UpperCAmelCase__	:str      =      '''teddy bear playing in the pool'''

    UpperCAmelCase__	:str      =      torch.Generator(device=__lowerCamelCase ).manual_seed(0 )
    UpperCAmelCase__	:Union[str, Any]      =      pipe([prompt]			,       generator=__lowerCamelCase			,       num_inference_steps=2			,       output_type='''np''' )
    UpperCAmelCase__	:Any      =      output.images

    UpperCAmelCase__	:Optional[int]      =      torch.Generator(device=__lowerCamelCase ).manual_seed(0 )
    UpperCAmelCase__	:int      =      pipe(
        [prompt]			,       generator=__lowerCamelCase			,       output_type='''np'''			,       return_dict=__lowerCamelCase			,       num_inference_steps=2 )[0]

    UpperCAmelCase__	:List[Any]      =      image[0, -3:, -3:, -1]
    UpperCAmelCase__	:Optional[Any]      =      image_from_tuple[0, -3:, -3:, -1]

    assert image.shape == (1, 2_4, 2_4, 3)

    UpperCAmelCase__	:Union[str, Any]      =      np.array([0.66_93, 0.60_75, 0.49_59, 0.57_01, 0.55_83, 0.43_33, 0.61_71, 0.56_84, 0.49_88] )

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




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


 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							:	Optional[int] ):
    UpperCAmelCase__	:Optional[Any]      =      load_numpy(
        '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
        '''/vq_diffusion/teddy_bear_pool_classifier_free_sampling.npy''' )

    UpperCAmelCase__	:Optional[Any]      =      VQDiffusionPipeline.from_pretrained('''microsoft/vq-diffusion-ithq''' )
    UpperCAmelCase__	:List[str]      =      pipeline.to(__lowerCamelCase )
    pipeline.set_progress_bar_config(disable=__lowerCamelCase )

    # requires GPU generator for gumbel softmax
    # don't use GPU generator in tests though
    UpperCAmelCase__	:int      =      torch.Generator(device=__lowerCamelCase ).manual_seed(0 )
    UpperCAmelCase__	:Union[str, Any]      =      pipeline(
        '''teddy bear playing in the pool'''			,       num_images_per_prompt=1			,       generator=__lowerCamelCase			,       output_type='''np'''			,       )

    UpperCAmelCase__	:List[str]      =      output.images[0]

    assert image.shape == (2_5_6, 2_5_6, 3)
    assert np.abs(expected_image - image ).max() < 2.0



