code: 
  
  
  """simple docstring"""
  
  
  
  
  import gc
  import tempfile
  import unittest
  
  import numpy as np
  import torch
  
  from diffusers import VersatileDiffusionDualGuidedPipeline
  from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device
  
  
  __SCREAMING_SNAKE_CASE					=						False
  
  
  
  
  
  @nightly
  @require_torch_gpu
  class __snake_case		(					unittest.TestCase      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Optional[int]       ):
            # clean up the VRAM after each test
            super().tearDown()
            gc.collect()
            torch.cuda.empty_cache()
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Dict       ):
            _a          =				VersatileDiffusionDualGuidedPipeline.from_pretrained("shi-labs/versatile-diffusion"       )
            # remove text_unet
            pipe.remove_unused_weights()
            pipe.to(UpperCamelCase__       )
            pipe.set_progress_bar_config(disable=UpperCamelCase__       )
  
            _a          =				load_image(
                "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg"       )
  
            _a          =				torch.manual_seed(0       )
            _a          =				pipe(
                prompt="first prompt"				,  image=UpperCamelCase__				,  text_to_image_strength=0.75				,  generator=UpperCamelCase__				,  guidance_scale=7.5				,  num_inference_steps=2				,  output_type="numpy"				,  ).images
  
            with tempfile.TemporaryDirectory() as tmpdirname:
                   pipe.save_pretrained(UpperCamelCase__       )
                   _a          =				VersatileDiffusionDualGuidedPipeline.from_pretrained(UpperCamelCase__       )
  
            pipe.to(UpperCamelCase__       )
            pipe.set_progress_bar_config(disable=UpperCamelCase__       )
  
            _a          =				generator.manual_seed(0       )
            _a          =				pipe(
                prompt="first prompt"				,  image=UpperCamelCase__				,  text_to_image_strength=0.75				,  generator=UpperCamelCase__				,  guidance_scale=7.5				,  num_inference_steps=2				,  output_type="numpy"				,  ).images
  
            assert np.abs(image - new_image       ).sum() < 1E-5, "Models don't have the same forward pass"
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Union[str, Any]       ):
            _a          =				VersatileDiffusionDualGuidedPipeline.from_pretrained("shi-labs/versatile-diffusion"       )
            pipe.remove_unused_weights()
            pipe.to(UpperCamelCase__       )
            pipe.set_progress_bar_config(disable=UpperCamelCase__       )
  
            _a          =				"cyberpunk 2077"
            _a          =				load_image(
                "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg"       )
            _a          =				torch.manual_seed(0       )
            _a          =				pipe(
                prompt=UpperCamelCase__				,  image=UpperCamelCase__				,  text_to_image_strength=0.75				,  generator=UpperCamelCase__				,  guidance_scale=7.5				,  num_inference_steps=50				,  output_type="numpy"				,  ).images
  
            _a          =				image[0, 253:256, 253:256, -1]
  
            assert image.shape == (1, 512, 512, 3)
            _a          =				np.array([0.0787, 0.0849, 0.0826, 0.0812, 0.0807, 0.0795, 0.0818, 0.0798, 0.0779]       )
  
            assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1E-2
  
style_context: 
  
  
  """simple docstring"""
  
  
  
  
  from __future__ import annotations
  
  
  
  def 						__a      (  a,		a					):
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
  
         assert len(a					) == len(a					)
  
         _a          =				len(a					)
         _a          =				list(range(a					)					)
         _a          =				[-1] * n  # who the donor has donated to
         _a          =				[-1] * n  # who the recipient has received from
         _a          =				[0] * n
  
         while unmatched_donors:
                _a          =				unmatched_donors[0]
                _a          =				donor_pref[donor]
                _a          =				donor_preference[num_donations[donor]]
                num_donations[donor] += 1
                _a          =				recipient_pref[recipient]
                _a          =				rec_record[recipient]
  
                if prev_donor != -1:
                       if rec_preference.index(a					) > rec_preference.index(a					):
                              _a          =				donor
                              _a          =				recipient
                              unmatched_donors.append(a					)
                              unmatched_donors.remove(a					)
                else:
                       _a          =				donor
                       _a          =				recipient
                       unmatched_donors.remove(a					)
         return donor_record
  