code: '''simple docstring'''
  
  
  
  
  
  import random
  import unittest
  
  import torch
  
  from diffusers import IFSuperResolutionPipeline
  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  lowerCAmelCase__   (       UpperCamelCase					,							UpperCamelCase					,							unittest.TestCase       ):
  
  
  
    '''simple docstring'''
  
  
  
  
  
  
    _UpperCamelCase						= IFSuperResolutionPipeline
    _UpperCamelCase						= TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {'width', 'height'}
    _UpperCamelCase						= TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
    _UpperCamelCase						= PipelineTesterMixin.required_optional_params - {'latents'}
  
    def 		_lowerCamelCase	(self  : Tuple    )   ->       Dict:
          return self._get_superresolution_dummy_components()
  
    def 		_lowerCamelCase	(self  : Optional[Any]	, lowerCAmelCase_  : int	, lowerCAmelCase_  : str=0    )   ->       Dict:
          if str(lowerCAmelCase_    ).startswith("mps"    ):
                snake_case_						       =							torch.manual_seed(lowerCAmelCase_    )
          else:
                snake_case_						       =							torch.Generator(device=lowerCAmelCase_    ).manual_seed(lowerCAmelCase_    )
  
          snake_case_						       =							floats_tensor((1, 3, 32, 32)	, rng=random.Random(lowerCAmelCase_    )    ).to(lowerCAmelCase_    )
  
          snake_case_						       =							{
              "prompt": "A painting of a squirrel eating a burger",
              "image": image,
              "generator": generator,
              "num_inference_steps": 2,
              "output_type": "numpy",
          }
  
          return inputs
  
    @unittest.skipIf(
        torch_device != "cuda" or not is_xformers_available()	, reason="XFormers attention is only available with CUDA and `xformers` installed"	, )
    def 		_lowerCamelCase	(self  : List[Any]    )   ->       int:
          self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1E-3    )
  
    def 		_lowerCamelCase	(self  : int    )   ->       str:
          self._test_save_load_optional_components()
  
    @unittest.skipIf(torch_device != "cuda"	, reason="float16 requires CUDA"    )
    def 		_lowerCamelCase	(self  : str    )   ->       List[str]:
          # Due to non-determinism in save load of the hf-internal-testing/tiny-random-t5 text encoder
          super().test_save_load_floataa(expected_max_diff=1E-1    )
  
    def 		_lowerCamelCase	(self  : Dict    )   ->       Optional[Any]:
          self._test_attention_slicing_forward_pass(expected_max_diff=1E-2    )
  
    def 		_lowerCamelCase	(self  : Union[str, Any]    )   ->       List[Any]:
          self._test_save_load_local()
  
  
    def 		_lowerCamelCase	(self  : List[Any]    )   ->       List[Any]:
          self._test_inference_batch_single_identical(
              expected_max_diff=1E-2	, )
  
  
style_context: 
  '''simple docstring'''
  
  
  
  
  
  from __future__ import annotations
  
  import random
  
  
  
  class  lowerCAmelCase__   :
  
  
  
    '''simple docstring'''
  
  
  
  
  
  
    _UpperCamelCase						= 6
  
    def __init__(self  : List[Any]    )   ->       Optional[Any]:
          snake_case_						       =							list(range(1	, Dice.NUM_SIDES + 1    )    )
  
  
    def 		_lowerCamelCase	(self  : Optional[int]    )   ->       int:
          return random.choice(self.sides    )
  
  def   snake_case_       (							_a     :							int ,					_a     :							int = 2			):
        snake_case_						       =							[Dice() for i in range(_a			)]
        snake_case_						       =							[0] * (len(_a			) * Dice.NUM_SIDES + 1)
        for _ in range(_a			):
              count_of_sum[sum(dice.roll() for dice in dices			)] += 1
        snake_case_						       =							[round((count * 100) / num_throws ,					2			) for count in count_of_sum]
        return probability[num_dice:]  # remove probability of sums that never appear
  
  
  if __name__ == "__main__":
       import doctest
  
       doctest.testmod()
  
  