





'''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,
    DDIMScheduler,
    EulerAncestralDiscreteScheduler,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionInstructPixaPixPipeline,
    UNetaDConditionModel,
)
from diffusers.image_processor import VaeImageProcessor
from diffusers.utils import floats_tensor, load_image, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu

from ..pipeline_params import (
    IMAGE_TO_IMAGE_IMAGE_PARAMS,
    TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_PARAMS,
)
from ..test_pipelines_common import PipelineKarrasSchedulerTesterMixin, PipelineLatentTesterMixin, PipelineTesterMixin


enable_full_determinism()


class 					__a      (lowerCamelCase       ,		lowerCamelCase       ,		lowerCamelCase       ,		unittest.TestCase     ):
							__a					:   Dict									=       StableDiffusionInstructPixaPixPipeline
							__a					:   Optional[Any]									=       TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {"height", "width", "cross_attention_kwargs"}
							__a					:   Any									=       TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS
							__a					:   int									=       IMAGE_TO_IMAGE_IMAGE_PARAMS
							__a					:   List[Any]									=       IMAGE_TO_IMAGE_IMAGE_PARAMS

							def     UpperCAmelCase__	(							self							:     Dict   )					->       Tuple:







													"""simple docstring"""
													torch.manual_seed(0   )
													UpperCAmelCase_			:      Dict     						=  UNetaDConditionModel(
													    block_out_channels=(32, 64)       ,     layers_per_block=2       ,     sample_size=32       ,     in_channels=8       ,     out_channels=4       ,     down_block_types=('''DownBlock2D''', '''CrossAttnDownBlock2D''')       ,     up_block_types=('''CrossAttnUpBlock2D''', '''UpBlock2D''')       ,     cross_attention_dim=32       ,     )
													UpperCAmelCase_			:      int     						=  PNDMScheduler(skip_prk_steps=__magic_name__   )
													torch.manual_seed(0   )
													UpperCAmelCase_			:      int     						=  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       ,     )
													torch.manual_seed(0   )
													UpperCAmelCase_			:      List[Any]     						=  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=10_00       ,     )
													UpperCAmelCase_			:      int     						=  CLIPTextModel(__magic_name__   )
													UpperCAmelCase_			:      List[Any]     						=  CLIPTokenizer.from_pretrained('''hf-internal-testing/tiny-random-clip'''   )

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

							def     UpperCAmelCase__	(							self							:     Any       ,     __magic_name__							:     Optional[Any]       ,     __magic_name__							:     Union[str, Any]=0   )					->       Optional[Any]:







													"""simple docstring"""
													UpperCAmelCase_			:      List[Any]     						=  floats_tensor((1, 3, 32, 32)       ,     rng=random.Random(__magic_name__   )   ).to(__magic_name__   )
													UpperCAmelCase_			:      Tuple     						=  image.cpu().permute(0       ,     2       ,     3       ,     1   )[0]
													UpperCAmelCase_			:      Any     						=  Image.fromarray(np.uinta(__magic_name__   )   ).convert('''RGB'''   )
													if str(__magic_name__   ).startswith('''mps'''   ):
																			UpperCAmelCase_			:      List[str]     						=  torch.manual_seed(__magic_name__   )
													else:
																			UpperCAmelCase_			:      Union[str, Any]     						=  torch.Generator(device=__magic_name__   ).manual_seed(__magic_name__   )
													UpperCAmelCase_			:      Dict     						=  {
													    '''prompt''': '''A painting of a squirrel eating a burger''',
													    '''image''': image,
													    '''generator''': generator,
													    '''num_inference_steps''': 2,
													    '''guidance_scale''': 6.0,
													    '''image_guidance_scale''': 1,
													    '''output_type''': '''numpy''',
													}
													return inputs

							def     UpperCAmelCase__	(							self							:     List[Any]   )					->       Optional[Any]:







													"""simple docstring"""
													UpperCAmelCase_			:      int     						=  '''cpu'''  # ensure determinism for the device-dependent torch.Generator
													UpperCAmelCase_			:      str     						=  self.get_dummy_components()
													UpperCAmelCase_			:      Optional[int]     						=  StableDiffusionInstructPixaPixPipeline(**__magic_name__   )
													UpperCAmelCase_			:      Optional[int]     						=  sd_pipe.to(__magic_name__   )
													sd_pipe.set_progress_bar_config(disable=__magic_name__   )

													UpperCAmelCase_			:      Tuple     						=  self.get_dummy_inputs(__magic_name__   )
													UpperCAmelCase_			:      Tuple     						=  sd_pipe(**__magic_name__   ).images
													UpperCAmelCase_			:      List[Any]     						=  image[0, -3:, -3:, -1]
													assert image.shape == (1, 32, 32, 3)
													UpperCAmelCase_			:      List[str]     						=  np.array([0.7_5_2_6, 0.3_7_5_0, 0.4_5_4_7, 0.6_1_1_7, 0.5_8_6_6, 0.5_0_1_6, 0.4_3_2_7, 0.5_6_4_2, 0.4_8_1_5]   )

													assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1E-3

							def     UpperCAmelCase__	(							self							:     Optional[int]   )					->       int:







													"""simple docstring"""
													UpperCAmelCase_			:      Optional[Any]     						=  '''cpu'''  # ensure determinism for the device-dependent torch.Generator
													UpperCAmelCase_			:      Tuple     						=  self.get_dummy_components()
													UpperCAmelCase_			:      List[str]     						=  StableDiffusionInstructPixaPixPipeline(**__magic_name__   )
													UpperCAmelCase_			:      Tuple     						=  sd_pipe.to(__magic_name__   )
													sd_pipe.set_progress_bar_config(disable=__magic_name__   )

													UpperCAmelCase_			:      Dict     						=  self.get_dummy_inputs(__magic_name__   )
													UpperCAmelCase_			:      int     						=  '''french fries'''
													UpperCAmelCase_			:      List[Any]     						=  sd_pipe(**__magic_name__       ,     negative_prompt=__magic_name__   )
													UpperCAmelCase_			:      List[str]     						=  output.images
													UpperCAmelCase_			:      str     						=  image[0, -3:, -3:, -1]

													assert image.shape == (1, 32, 32, 3)
													UpperCAmelCase_			:      int     						=  np.array([0.7_5_1_1, 0.3_6_4_2, 0.4_5_5_3, 0.6_2_3_6, 0.5_7_9_7, 0.5_0_1_3, 0.4_3_4_3, 0.5_6_1_1, 0.4_8_3_1]   )

													assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1E-3

							def     UpperCAmelCase__	(							self							:     Any   )					->       str:







													"""simple docstring"""
													UpperCAmelCase_			:      Any     						=  '''cpu'''  # ensure determinism for the device-dependent torch.Generator
													UpperCAmelCase_			:      str     						=  self.get_dummy_components()
													UpperCAmelCase_			:      Dict     						=  StableDiffusionInstructPixaPixPipeline(**__magic_name__   )
													UpperCAmelCase_			:      Union[str, Any]     						=  sd_pipe.to(__magic_name__   )
													sd_pipe.set_progress_bar_config(disable=__magic_name__   )

													UpperCAmelCase_			:      int     						=  self.get_dummy_inputs(__magic_name__   )
													UpperCAmelCase_			:      Tuple     						=  [inputs['''prompt''']] * 2

													UpperCAmelCase_			:      Tuple     						=  np.array(inputs['''image''']   ).astype(np.floataa   ) / 2_5_5.0
													UpperCAmelCase_			:      Optional[int]     						=  torch.from_numpy(__magic_name__   ).unsqueeze(0   ).to(__magic_name__   )
													UpperCAmelCase_			:      Union[str, Any]     						=  image / 2 + 0.5
													UpperCAmelCase_			:      int     						=  image.permute(0       ,     3       ,     1       ,     2   )
													UpperCAmelCase_			:      Dict     						=  image.repeat(2       ,     1       ,     1       ,     1   )

													UpperCAmelCase_			:      Dict     						=  sd_pipe(**__magic_name__   ).images
													UpperCAmelCase_			:      Any     						=  image[-1, -3:, -3:, -1]

													assert image.shape == (2, 32, 32, 3)
													UpperCAmelCase_			:      Any     						=  np.array([0.5_8_1_2, 0.5_7_4_8, 0.5_2_2_2, 0.5_9_0_8, 0.5_6_9_5, 0.7_1_7_4, 0.6_8_0_4, 0.5_5_2_3, 0.5_5_7_9]   )

													assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1E-3

							def     UpperCAmelCase__	(							self							:     Optional[int]   )					->       int:







													"""simple docstring"""
													UpperCAmelCase_			:      Tuple     						=  '''cpu'''  # ensure determinism for the device-dependent torch.Generator
													UpperCAmelCase_			:      str     						=  self.get_dummy_components()
													UpperCAmelCase_			:      List[Any]     						=  EulerAncestralDiscreteScheduler(
													    beta_start=0.0_0_0_8_5       ,     beta_end=0.0_1_2       ,     beta_schedule='''scaled_linear'''   )
													UpperCAmelCase_			:      Union[str, Any]     						=  StableDiffusionInstructPixaPixPipeline(**__magic_name__   )
													UpperCAmelCase_			:      Dict     						=  sd_pipe.to(__magic_name__   )
													sd_pipe.set_progress_bar_config(disable=__magic_name__   )

													UpperCAmelCase_			:      Union[str, Any]     						=  self.get_dummy_inputs(__magic_name__   )
													UpperCAmelCase_			:      Union[str, Any]     						=  sd_pipe(**__magic_name__   ).images
													UpperCAmelCase_			:      int     						=  image[0, -3:, -3:, -1]

													UpperCAmelCase_			:      List[Any]     						=  [round(__magic_name__       ,     4   ) for x in image_slice.flatten().tolist()]
													print(''','''.join([str(__magic_name__   ) for x in slice]   )   )

													assert image.shape == (1, 32, 32, 3)
													UpperCAmelCase_			:      List[str]     						=  np.array([0.7_4_1_7, 0.3_8_4_2, 0.4_7_3_2, 0.5_7_7_6, 0.5_8_9_1, 0.5_1_3_9, 0.4_0_5_2, 0.5_6_7_3, 0.4_9_8_6]   )

													assert np.abs(image_slice.flatten() - expected_slice   ).max() < 1E-3

							def     UpperCAmelCase__	(							self							:     List[str]   )					->       Optional[int]:







													"""simple docstring"""
													super().test_inference_batch_single_identical(expected_max_diff=3E-3   )



							def     UpperCAmelCase__	(							self							:     Union[str, Any]   )					->       Any:







													"""simple docstring"""
													UpperCAmelCase_			:      Any     						=  self.get_dummy_components()
													UpperCAmelCase_			:      Dict     						=  StableDiffusionInstructPixaPixPipeline(**__magic_name__   )
													UpperCAmelCase_			:      Tuple     						=  VaeImageProcessor(do_resize=__magic_name__       ,     do_normalize=__magic_name__   )
													UpperCAmelCase_			:      List[Any]     						=  pipe.to(__magic_name__   )
													pipe.set_progress_bar_config(disable=__magic_name__   )

													UpperCAmelCase_			:      List[str]     						=  pipe(**self.get_dummy_inputs_by_type(__magic_name__       ,     input_image_type='''pt'''   )   )[0]

													UpperCAmelCase_			:      Optional[Any]     						=  components['''vae''']
													UpperCAmelCase_			:      Tuple     						=  self.get_dummy_inputs_by_type(__magic_name__       ,     input_image_type='''pt'''   )

													for image_param in self.image_latents_params:
																			if image_param in inputs.keys():
																									UpperCAmelCase_			:      Optional[int]     						=  vae.encode(inputs[image_param]   ).latent_dist.mode()

													UpperCAmelCase_			:      List[str]     						=  pipe(**__magic_name__   )[0]

													UpperCAmelCase_			:      Optional[Any]     						=  np.abs(out - out_latents_inputs   ).max()
													self.assertLess(__magic_name__       ,     1E-4       ,     '''passing latents as image input generate different result from passing image'''   )





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

							def     UpperCAmelCase__	(							self							:     str   )					->       List[Any]:







													"""simple docstring"""
													super().tearDown()
													gc.collect()
													torch.cuda.empty_cache()

							def     UpperCAmelCase__	(							self							:     Union[str, Any]       ,     __magic_name__							:     Optional[int]=0   )					->       Optional[int]:







													"""simple docstring"""
													UpperCAmelCase_			:      List[str]     						=  torch.manual_seed(__magic_name__   )
													UpperCAmelCase_			:      Tuple     						=  load_image(
													    '''https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_pix2pix/example.jpg'''   )
													UpperCAmelCase_			:      int     						=  {
													    '''prompt''': '''turn him into a cyborg''',
													    '''image''': image,
													    '''generator''': generator,
													    '''num_inference_steps''': 3,
													    '''guidance_scale''': 7.5,
													    '''image_guidance_scale''': 1.0,
													    '''output_type''': '''numpy''',
													}
													return inputs

							def     UpperCAmelCase__	(							self							:     str   )					->       Optional[int]:







													"""simple docstring"""
													UpperCAmelCase_			:      List[Any]     						=  StableDiffusionInstructPixaPixPipeline.from_pretrained(
													    '''timbrooks/instruct-pix2pix'''       ,     safety_checker=__magic_name__   )
													pipe.to(__magic_name__   )
													pipe.set_progress_bar_config(disable=__magic_name__   )
													pipe.enable_attention_slicing()

													UpperCAmelCase_			:      List[str]     						=  self.get_inputs()
													UpperCAmelCase_			:      List[Any]     						=  pipe(**__magic_name__   ).images
													UpperCAmelCase_			:      int     						=  image[0, -3:, -3:, -1].flatten()

													assert image.shape == (1, 5_12, 5_12, 3)
													UpperCAmelCase_			:      Optional[Any]     						=  np.array([0.5_9_0_2, 0.6_0_1_5, 0.6_0_2_7, 0.5_9_8_3, 0.6_0_9_2, 0.6_0_6_1, 0.5_7_6_5, 0.5_7_8_5, 0.5_5_5_5]   )

													assert np.abs(expected_slice - image_slice   ).max() < 1E-3

							def     UpperCAmelCase__	(							self							:     List[Any]   )					->       Optional[int]:







													"""simple docstring"""
													UpperCAmelCase_			:      Union[str, Any]     						=  StableDiffusionInstructPixaPixPipeline.from_pretrained(
													    '''timbrooks/instruct-pix2pix'''       ,     safety_checker=__magic_name__   )
													UpperCAmelCase_			:      List[str]     						=  LMSDiscreteScheduler.from_config(pipe.scheduler.config   )
													pipe.to(__magic_name__   )
													pipe.set_progress_bar_config(disable=__magic_name__   )
													pipe.enable_attention_slicing()

													UpperCAmelCase_			:      int     						=  self.get_inputs()
													UpperCAmelCase_			:      List[str]     						=  pipe(**__magic_name__   ).images
													UpperCAmelCase_			:      Tuple     						=  image[0, -3:, -3:, -1].flatten()

													assert image.shape == (1, 5_12, 5_12, 3)
													UpperCAmelCase_			:      List[str]     						=  np.array([0.6_5_7_8, 0.6_8_1_7, 0.6_9_7_2, 0.6_7_6_1, 0.6_8_5_6, 0.6_9_1_6, 0.6_4_2_8, 0.6_5_1_6, 0.6_3_0_1]   )

													assert np.abs(expected_slice - image_slice   ).max() < 1E-3

							def     UpperCAmelCase__	(							self							:     Optional[int]   )					->       str:







													"""simple docstring"""
													UpperCAmelCase_			:      Optional[Any]     						=  StableDiffusionInstructPixaPixPipeline.from_pretrained(
													    '''timbrooks/instruct-pix2pix'''       ,     safety_checker=__magic_name__   )
													UpperCAmelCase_			:      Any     						=  DDIMScheduler.from_config(pipe.scheduler.config   )
													pipe.to(__magic_name__   )
													pipe.set_progress_bar_config(disable=__magic_name__   )
													pipe.enable_attention_slicing()

													UpperCAmelCase_			:      int     						=  self.get_inputs()
													UpperCAmelCase_			:      Optional[Any]     						=  pipe(**__magic_name__   ).images
													UpperCAmelCase_			:      str     						=  image[0, -3:, -3:, -1].flatten()

													assert image.shape == (1, 5_12, 5_12, 3)
													UpperCAmelCase_			:      str     						=  np.array([0.3_8_2_8, 0.3_8_3_4, 0.3_8_1_8, 0.3_7_9_2, 0.3_8_6_5, 0.3_7_5_2, 0.3_7_9_2, 0.3_8_4_7, 0.3_7_5_3]   )

													assert np.abs(expected_slice - image_slice   ).max() < 1E-3

							def     UpperCAmelCase__	(							self							:     int   )					->       Any:







													"""simple docstring"""
													UpperCAmelCase_			:      Optional[int]     						=  0

													def callback_fn(__magic_name__							:     int       ,     __magic_name__							:     int       ,     __magic_name__							:     torch.FloatTensor   ) -> None:
																			UpperCAmelCase_			:      Any     						=  True
																			nonlocal number_of_steps
																			number_of_steps += 1
																			if step == 1:
																									UpperCAmelCase_			:      int     						=  latents.detach().cpu().numpy()
																									assert latents.shape == (1, 4, 64, 64)
																									UpperCAmelCase_			:      str     						=  latents[0, -3:, -3:, -1]
																									UpperCAmelCase_			:      Tuple     						=  np.array([-0.2_4_6_3, -0.4_6_4_4, -0.9_7_5_6, 1.5_1_7_6, 1.4_4_1_4, 0.7_8_6_6, 0.9_8_9_7, 0.8_5_2_1, 0.7_9_8_3]   )

																									assert np.abs(latents_slice.flatten() - expected_slice   ).max() < 5E-2
																			elif step == 2:
																									UpperCAmelCase_			:      List[Any]     						=  latents.detach().cpu().numpy()
																									assert latents.shape == (1, 4, 64, 64)
																									UpperCAmelCase_			:      Optional[Any]     						=  latents[0, -3:, -3:, -1]
																									UpperCAmelCase_			:      Optional[Any]     						=  np.array([-0.2_6_4_4, -0.4_6_2_6, -0.9_6_5_3, 1.5_1_7_6, 1.4_5_5_1, 0.7_6_8_6, 0.9_8_0_5, 0.8_4_5_2, 0.8_1_1_5]   )

																									assert np.abs(latents_slice.flatten() - expected_slice   ).max() < 5E-2

													UpperCAmelCase_			:      Optional[Any]     						=  False

													UpperCAmelCase_			:      Dict     						=  StableDiffusionInstructPixaPixPipeline.from_pretrained(
													    '''timbrooks/instruct-pix2pix'''       ,     safety_checker=__magic_name__       ,     torch_dtype=torch.floataa   )
													UpperCAmelCase_			:      List[str]     						=  pipe.to(__magic_name__   )
													pipe.set_progress_bar_config(disable=__magic_name__   )
													pipe.enable_attention_slicing()

													UpperCAmelCase_			:      List[Any]     						=  self.get_inputs()
													pipe(**__magic_name__       ,     callback=__magic_name__       ,     callback_steps=1   )
													assert callback_fn.has_been_called
													assert number_of_steps == 3

							def     UpperCAmelCase__	(							self							:     Union[str, Any]   )					->       List[str]:







													"""simple docstring"""
													torch.cuda.empty_cache()
													torch.cuda.reset_max_memory_allocated()
													torch.cuda.reset_peak_memory_stats()

													UpperCAmelCase_			:      str     						=  StableDiffusionInstructPixaPixPipeline.from_pretrained(
													    '''timbrooks/instruct-pix2pix'''       ,     safety_checker=__magic_name__       ,     torch_dtype=torch.floataa   )
													UpperCAmelCase_			:      Dict     						=  pipe.to(__magic_name__   )
													pipe.set_progress_bar_config(disable=__magic_name__   )
													pipe.enable_attention_slicing(1   )
													pipe.enable_sequential_cpu_offload()

													UpperCAmelCase_			:      int     						=  self.get_inputs()
													UpperCAmelCase_			:      Optional[Any]     						=  pipe(**__magic_name__   )

													UpperCAmelCase_			:      Optional[int]     						=  torch.cuda.max_memory_allocated()
													# make sure that less than 2.2 GB is allocated
													assert mem_bytes < 2.2 * 10**9



							def     UpperCAmelCase__	(							self							:     str   )					->       Union[str, Any]:







													"""simple docstring"""
													UpperCAmelCase_			:      Optional[Any]     						=  self.get_inputs()
													# resize to resolution that is divisible by 8 but not 16 or 32
													UpperCAmelCase_			:      Optional[Any]     						=  inputs['''image'''].resize((5_04, 5_04)   )

													UpperCAmelCase_			:      Union[str, Any]     						=  '''timbrooks/instruct-pix2pix'''
													UpperCAmelCase_			:      List[str]     						=  StableDiffusionInstructPixaPixPipeline.from_pretrained(
													    __magic_name__       ,     safety_checker=__magic_name__       ,     )
													pipe.to(__magic_name__   )
													pipe.set_progress_bar_config(disable=__magic_name__   )
													pipe.enable_attention_slicing()

													UpperCAmelCase_			:      Optional[Any]     						=  pipe(**__magic_name__   )
													UpperCAmelCase_			:      int     						=  output.images[0]

													UpperCAmelCase_			:      Dict     						=  image[2_55:2_58, 3_83:3_86, -1]

													assert image.shape == (5_04, 5_04, 3)
													UpperCAmelCase_			:      Tuple     						=  np.array([0.2_7_2_6, 0.2_5_2_9, 0.2_6_6_4, 0.2_6_5_5, 0.2_6_4_1, 0.2_6_4_2, 0.2_5_9_1, 0.2_6_4_9, 0.2_5_9_0]   )

													assert np.abs(image_slice.flatten() - expected_slice   ).max() < 5E-3












'''simple docstring'''







import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
					import torch

					from transformers.generation import DisjunctiveConstraint


@require_torch
class 					__a      (unittest.TestCase     ):

							def     UpperCAmelCase__	(							self							:     Optional[Any]   )					->       List[Any]:







													"""simple docstring"""
													# For consistency across different places the DisjunctiveConstraint is called,
													# dc.token_ids is a list of integers. It is also initialized only by integers.

													UpperCAmelCase_			:      List[str]     						=  [[1, 2, 4], [1, 2, 3, 4]]
													UpperCAmelCase_			:      List[str]     						=  DisjunctiveConstraint(__magic_name__   )
													self.assertTrue(isinstance(dc.token_ids       ,     __magic_name__   )   )

													with self.assertRaises(__magic_name__   ):
																			DisjunctiveConstraint(torch.LongTensor([[1, 2, 4], [1, 2, 3]]   )   )

													with self.assertRaises(__magic_name__   ):
																			DisjunctiveConstraint([torch.LongTensor([1, 2, 4]   ), torch.LongTensor([1, 2, 3, 4, 5]   )]   )

							def     UpperCAmelCase__	(							self							:     List[str]   )					->       Dict:







													"""simple docstring"""
													# We can't have constraints that are complete subsets of another. This leads to a preverse
													# interpretation of "constraint fulfillment": does generating [1,2,3] fulfill the constraint?
													# It would mean that it generated [1,2] which fulfills it, but it's in the middle of potentially
													# fulfilling [1,2,3,4]. If we believe that [1,2,3] does fulfill the constraint, then the algorithm
													# will necessarily never reach [1,2,3,4], giving users a false sense of control (better to just not allow it).
													UpperCAmelCase_			:      Tuple     						=  [[1, 2], [1, 2, 3, 4]]

													with self.assertRaises(__magic_name__   ):
																			DisjunctiveConstraint(__magic_name__   )  # fails here

							def     UpperCAmelCase__	(							self							:     Optional[int]   )					->       Union[str, Any]:







													"""simple docstring"""
													UpperCAmelCase_			:      Optional[int]     						=  [[1, 2, 3], [1, 2, 4]]

													UpperCAmelCase_			:      List[str]     						=  DisjunctiveConstraint(__magic_name__   )

													UpperCAmelCase_						,       UpperCAmelCase_						,       UpperCAmelCase_			:      List[Any]     						=  dc.update(1   )
													UpperCAmelCase_			:      Dict     						=  stepped is True and completed is False and reset is False
													self.assertTrue(__magic_name__   )
													self.assertTrue(not dc.completed   )
													self.assertTrue(dc.current_seq == [1]   )

													UpperCAmelCase_						,       UpperCAmelCase_						,       UpperCAmelCase_			:      str     						=  dc.update(2   )
													UpperCAmelCase_			:      Optional[Any]     						=  stepped is True and completed is False and reset is False
													self.assertTrue(__magic_name__   )
													self.assertTrue(not dc.completed   )
													self.assertTrue(dc.current_seq == [1, 2]   )

													UpperCAmelCase_						,       UpperCAmelCase_						,       UpperCAmelCase_			:      List[Any]     						=  dc.update(3   )
													UpperCAmelCase_			:      Dict     						=  stepped is True and completed is True and reset is False
													self.assertTrue(__magic_name__   )
													self.assertTrue(dc.completed   )  # Completed!
													self.assertTrue(dc.current_seq == [1, 2, 3]   )



							def     UpperCAmelCase__	(							self							:     int   )					->       Dict:







													"""simple docstring"""
													UpperCAmelCase_			:      Any     						=  [[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

													UpperCAmelCase_			:      Tuple     						=  DisjunctiveConstraint(__magic_name__   )

													UpperCAmelCase_						,       UpperCAmelCase_						,       UpperCAmelCase_			:      List[Any]     						=  dc.update(1   )
													self.assertTrue(not dc.completed   )
													self.assertTrue(dc.current_seq == [1]   )

													UpperCAmelCase_						,       UpperCAmelCase_						,       UpperCAmelCase_			:      Optional[int]     						=  dc.update(2   )
													self.assertTrue(not dc.completed   )
													self.assertTrue(dc.current_seq == [1, 2]   )

													UpperCAmelCase_						,       UpperCAmelCase_						,       UpperCAmelCase_			:      int     						=  dc.update(4   )
													self.assertTrue(not dc.completed   )
													self.assertTrue(dc.current_seq == [1, 2, 4]   )

													UpperCAmelCase_						,       UpperCAmelCase_						,       UpperCAmelCase_			:      int     						=  dc.update(5   )
													self.assertTrue(dc.completed   )  # Completed!
													self.assertTrue(dc.current_seq == [1, 2, 4, 5]   )

													dc.reset()

													UpperCAmelCase_						,       UpperCAmelCase_						,       UpperCAmelCase_			:      List[Any]     						=  dc.update(1   )
													self.assertTrue(not dc.completed   )
													self.assertTrue(dc.remaining() == 3   )
													self.assertTrue(dc.current_seq == [1]   )

													UpperCAmelCase_						,       UpperCAmelCase_						,       UpperCAmelCase_			:      Optional[Any]     						=  dc.update(2   )
													self.assertTrue(not dc.completed   )
													self.assertTrue(dc.remaining() == 2   )
													self.assertTrue(dc.current_seq == [1, 2]   )

													UpperCAmelCase_						,       UpperCAmelCase_						,       UpperCAmelCase_			:      Optional[int]     						=  dc.update(5   )
													self.assertTrue(dc.completed   )  # Completed!
													self.assertTrue(dc.remaining() == 0   )
													self.assertTrue(dc.current_seq == [1, 2, 5]   )





