"""simple docstring"""







from .hash_table import HashTable
from .number_theory.prime_numbers import is_prime, next_prime






class 							__snake_case(					A_	):


    '''simple docstring'''





    def __init__(  self					,       *__lowerCamelCase					,       **__lowerCamelCase	):




         '''simple docstring'''



         super().__init__(*__lowerCamelCase					,       **__lowerCamelCase	)
    def 						_a							(  self					,       __lowerCamelCase					,       __lowerCamelCase	):




         '''simple docstring'''



         __A					:					str								=		(
             next_prime(value % self.size_table	)
             if not is_prime(value % self.size_table	)
             else value % self.size_table
         )  # gt = bigger than
         return next_prime_gt - (data % next_prime_gt)
    def 						_a							(  self					,       __lowerCamelCase					,       __lowerCamelCase					,       __lowerCamelCase	):




         '''simple docstring'''



         return (increment * self.__hash_function_a(__lowerCamelCase					,       __lowerCamelCase	)) % self.size_table

    def 						_a							(  self					,       __lowerCamelCase					,       __lowerCamelCase=None	):




         '''simple docstring'''



         __A					:					Tuple								=		1
         __A					:					Any								=		self.hash_function(__lowerCamelCase	)

         while self.values[new_key] is not None and self.values[new_key] != key:
              __A					:					int								=		(
                  self.__hash_double_function(__lowerCamelCase					,       __lowerCamelCase					,       __lowerCamelCase	)
                  if self.balanced_factor() >= self.lim_charge
                  else None
              )
              if new_key is None:
                   break
              else:
                   i += 1

         return new_key




"""simple docstring"""







import random
import unittest

import torch

from diffusers import IFImgaImgPipeline
from diffusers.utils import floats_tensor
from diffusers.utils.import_utils import is_xformers_available
from diffusers.utils.testing_utils import skip_mps, torch_device

from ..pipeline_params import (
    TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_PARAMS,
)
from ..test_pipelines_common import PipelineTesterMixin
from . import IFPipelineTesterMixin






@skip_mps
class 							__snake_case(					A_				,	A_				,	unittest.TestCase	):


    '''simple docstring'''





    _UpperCAmelCase       =			IFImgaImgPipeline
    _UpperCAmelCase       =			TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {"width", "height"}
    _UpperCAmelCase       =			TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
    _UpperCAmelCase       =			PipelineTesterMixin.required_optional_params - {"latents"}
    def 						_a							(  self	):




         '''simple docstring'''



         return self._get_dummy_components()
    def 						_a							(  self					,       __lowerCamelCase					,       __lowerCamelCase=0	):




         '''simple docstring'''



         if str(__lowerCamelCase	).startswith('mps'	):
              __A					:					Tuple								=		torch.manual_seed(__lowerCamelCase	)
         else:
              __A					:					int								=		torch.Generator(device=__lowerCamelCase	).manual_seed(__lowerCamelCase	)

         __A					:					str								=		floats_tensor((1, 3, 32, 32)					,       rng=random.Random(__lowerCamelCase	)	).to(__lowerCamelCase	)

         __A					:					str								=		{
             'prompt': 'A painting of a squirrel eating a burger',
             'image': image,
             'generator': generator,
             'num_inference_steps': 2,
             'output_type': 'numpy',
         }

         return inputs
    def 						_a							(  self	):




         '''simple docstring'''



         self._test_save_load_optional_components()
    @unittest.skipIf(
        torch_device != 'cuda' or not is_xformers_available()					,       reason='XFormers attention is only available with CUDA and `xformers` installed'					,       )
    def 						_a							(  self	):




         '''simple docstring'''



         self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1e-3	)
    @unittest.skipIf(torch_device != 'cuda'					,       reason='float16 requires CUDA'	)
    def 						_a							(  self	):




         '''simple docstring'''



         super().test_save_load_floataa(expected_max_diff=1e-1	)
    @unittest.skipIf(torch_device != 'cuda'					,       reason='float16 requires CUDA'	)
    def 						_a							(  self	):




         '''simple docstring'''



         super().test_floataa_inference(expected_max_diff=1e-1	)
    def 						_a							(  self	):




         '''simple docstring'''



         self._test_attention_slicing_forward_pass(expected_max_diff=1e-2	)
    def 						_a							(  self	):




         '''simple docstring'''



         self._test_save_load_local()

    def 						_a							(  self	):




         '''simple docstring'''



         self._test_inference_batch_single_identical(
             expected_max_diff=1e-2					,       )



