code: 
  """simple docstring"""
  
  
  
  
  
  import unittest
  
  import torch
  
  from diffusers import UNetaDModel
  from diffusers.utils import floats_tensor, slow, torch_device
  
  from .test_modeling_common import ModelTesterMixin, UNetTesterMixin
  
  
  class A_			(SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__       ,unittest.TestCase   ):
  
  
  
  
    '''simple docstring'''
    SCREAMING_SNAKE_CASE__    :		str						  =	UNetaDModel
    SCREAMING_SNAKE_CASE__    :		Tuple						  =	'sample'
  
  
  
  
  
  
  
    @property
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       UpperCAmelCase_      :      int      =					4
       UpperCAmelCase_      :      Optional[int]      =					14
       UpperCAmelCase_      :      Tuple      =					16
  
       UpperCAmelCase_      :      Tuple      =					floats_tensor((batch_size, num_features, seq_len)						).to(a_						)
       UpperCAmelCase_      :      List[Any]      =					torch.tensor([10] * batch_size						).to(a_						)
  
       return {"sample": noise, "timestep": time_step}
  
  
  
  
  
  
  
    @property
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       return (4, 14, 16)
  
  
  
  
  
  
  
    @property
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       return (4, 14, 16)
  
  
  
  
  
  
  
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       pass
  
  
  
  
  
  
  
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       pass
  
  
  
  
  
  
  
    @unittest.skipIf(torch_device == "mps"       ,     "mish op not supported in MPS"						)
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       super().test_determinism()
  
  
  
  
  
  
  
    @unittest.skipIf(torch_device == "mps"       ,     "mish op not supported in MPS"						)
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       super().test_outputs_equivalence()
  
  
  
  
  
  
  
    @unittest.skipIf(torch_device == "mps"       ,     "mish op not supported in MPS"						)
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       super().test_from_save_pretrained()
  
  
  
  
  
  
  
    @unittest.skipIf(torch_device == "mps"       ,     "mish op not supported in MPS"						)
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       super().test_from_save_pretrained_variant()
  
  
  
  
  
  
  
    @unittest.skipIf(torch_device == "mps"       ,     "mish op not supported in MPS"						)
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       super().test_model_from_pretrained()
  
  
  
  
  
  
  
    @unittest.skipIf(torch_device == "mps"       ,     "mish op not supported in MPS"						)
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       super().test_output()
  
  
  
  
  
  
  
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       UpperCAmelCase_      :      List[str]      =					{
           "block_out_channels": (32, 64, 128, 256),
           "in_channels": 14,
           "out_channels": 14,
           "time_embedding_type": "positional",
           "use_timestep_embedding": True,
           "flip_sin_to_cos": False,
           "freq_shift": 1.0,
           "out_block_type": "OutConv1DBlock",
           "mid_block_type": "MidResTemporalBlock1D",
           "down_block_types": ("DownResnetBlock1D", "DownResnetBlock1D", "DownResnetBlock1D", "DownResnetBlock1D"),
           "up_block_types": ("UpResnetBlock1D", "UpResnetBlock1D", "UpResnetBlock1D"),
           "act_fn": "mish",
       }
       UpperCAmelCase_      :      List[str]      =					self.dummy_input
       return init_dict, inputs_dict
  
  
  
  
  
  
  
    @unittest.skipIf(torch_device == "mps"       ,     "mish op not supported in MPS"						)
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       UpperCAmelCase_  ,     UpperCAmelCase_      :      Optional[Any]      =					UNetaDModel.from_pretrained(
           "bglick13/hopper-medium-v2-value-function-hor32"       ,     output_loading_info=a_       ,     subfolder="unet"						)
       self.assertIsNotNone(a_						)
       self.assertEqual(len(loading_info["missing_keys"]						)       ,     0						)
  
       model.to(a_						)
       UpperCAmelCase_      :      int      =					model(**self.dummy_input						)
  
       assert image is not None, "Make sure output is not None"
  
  
  
  
  
  
  
    @unittest.skipIf(torch_device == "mps"       ,     "mish op not supported in MPS"						)
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       UpperCAmelCase_      :      Union[str, Any]      =					UNetaDModel.from_pretrained("bglick13/hopper-medium-v2-value-function-hor32"       ,     subfolder="unet"						)
       torch.manual_seed(0						)
       if torch.cuda.is_available():
          torch.cuda.manual_seed_all(0						)
  
       UpperCAmelCase_      :      int      =					model.config.in_channels
       UpperCAmelCase_      :      Union[str, Any]      =					16
       UpperCAmelCase_      :      List[str]      =					torch.randn((1, seq_len, num_features)						).permute(
           0       ,     2       ,     1						)  # match original, we can update values and remove
       UpperCAmelCase_      :      int      =					torch.full((num_features,)       ,     0						)
  
       with torch.no_grad():
          UpperCAmelCase_      :      Dict      =					model(a_       ,     a_						).sample.permute(0       ,     2       ,     1						)
  
       UpperCAmelCase_      :      str      =					output[0, -3:, -3:].flatten()
       # fmt: off
       UpperCAmelCase_      :      Optional[int]      =					torch.tensor([-2.13_71_72, 1.1_42_60_16, 0.3_68_86_87, -0.76_69_22, 0.7_30_31_46, 0.11_03_88_64, -0.4_76_06_33, 0.13_27_01_72, 0.02_59_13_48]						)
       # fmt: on
       self.assertTrue(torch.allclose(a_       ,     a_       ,     rtol=1E-3						)						)
  
  
  
  
  
  
  
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       pass
  
  
  
  
  
  
  
    @slow
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       UpperCAmelCase_      :      List[str]      =					"harmonai/maestro-150k"
       UpperCAmelCase_      :      Tuple      =					UNetaDModel.from_pretrained(a_       ,     subfolder="unet"						)
       model.to(a_						)
  
       UpperCAmelCase_      :      Any      =					6_5536
       UpperCAmelCase_      :      List[str]      =					torch.sin(torch.arange(a_						)[None, None, :].repeat(1       ,     2       ,     1						)						).to(a_						)
       UpperCAmelCase_      :      int      =					torch.tensor([1]						).to(a_						)
  
       with torch.no_grad():
          UpperCAmelCase_      :      Union[str, Any]      =					model(a_       ,     a_						).sample
  
       UpperCAmelCase_      :      List[str]      =					output.abs().sum()
       UpperCAmelCase_      :      Union[str, Any]      =					output.abs().max()
  
       assert (output_sum - 2_24.08_96).abs() < 0.5
       assert (output_max - 0.06_07).abs() < 4E-4
  
  
  
  
  class A_			(SCREAMING_SNAKE_CASE__       ,SCREAMING_SNAKE_CASE__       ,unittest.TestCase   ):
  
  
  
  
    '''simple docstring'''
    SCREAMING_SNAKE_CASE__    :		int						  =	UNetaDModel
    SCREAMING_SNAKE_CASE__    :		Optional[int]						  =	'sample'
  
  
  
  
  
  
  
    @property
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       UpperCAmelCase_      :      List[Any]      =					4
       UpperCAmelCase_      :      Any      =					14
       UpperCAmelCase_      :      List[str]      =					16
  
       UpperCAmelCase_      :      Tuple      =					floats_tensor((batch_size, num_features, seq_len)						).to(a_						)
       UpperCAmelCase_      :      str      =					torch.tensor([10] * batch_size						).to(a_						)
  
       return {"sample": noise, "timestep": time_step}
  
  
  
  
  
  
  
    @property
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       return (4, 14, 16)
  
  
  
  
  
  
  
    @property
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       return (4, 14, 1)
  
  
  
  
  
  
  
    @unittest.skipIf(torch_device == "mps"       ,     "mish op not supported in MPS"						)
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       super().test_determinism()
  
  
  
  
  
  
  
    @unittest.skipIf(torch_device == "mps"       ,     "mish op not supported in MPS"						)
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       super().test_outputs_equivalence()
  
  
  
  
  
  
  
    @unittest.skipIf(torch_device == "mps"       ,     "mish op not supported in MPS"						)
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       super().test_from_save_pretrained()
  
  
  
  
  
  
  
    @unittest.skipIf(torch_device == "mps"       ,     "mish op not supported in MPS"						)
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       super().test_from_save_pretrained_variant()
  
  
  
  
  
  
  
    @unittest.skipIf(torch_device == "mps"       ,     "mish op not supported in MPS"						)
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       super().test_model_from_pretrained()
  
  
  
  
  
  
  
    @unittest.skipIf(torch_device == "mps"       ,     "mish op not supported in MPS"						)
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       UpperCAmelCase_  ,     UpperCAmelCase_      :      Tuple      =					self.prepare_init_args_and_inputs_for_common()
       UpperCAmelCase_      :      List[str]      =					self.model_class(**a_						)
       model.to(a_						)
       model.eval()
  
       with torch.no_grad():
          UpperCAmelCase_      :      int      =					model(**a_						)
  
          if isinstance(a_       ,     a_						):
             UpperCAmelCase_      :      Dict      =					output.sample
  
       self.assertIsNotNone(a_						)
       UpperCAmelCase_      :      Dict      =					torch.Size((inputs_dict["sample"].shape[0], 1)						)
       self.assertEqual(output.shape       ,     a_       ,     "Input and output shapes do not match"						)
  
  
  
  
  
  
  
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       pass
  
  
  
  
  
  
  
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       pass
  
  
  
  
  
  
  
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       UpperCAmelCase_      :      Any      =					{
           "in_channels": 14,
           "out_channels": 14,
           "down_block_types": ["DownResnetBlock1D", "DownResnetBlock1D", "DownResnetBlock1D", "DownResnetBlock1D"],
           "up_block_types": [],
           "out_block_type": "ValueFunction",
           "mid_block_type": "ValueFunctionMidBlock1D",
           "block_out_channels": [32, 64, 128, 256],
           "layers_per_block": 1,
           "downsample_each_block": True,
           "use_timestep_embedding": True,
           "freq_shift": 1.0,
           "flip_sin_to_cos": False,
           "time_embedding_type": "positional",
           "act_fn": "mish",
       }
       UpperCAmelCase_      :      int      =					self.dummy_input
       return init_dict, inputs_dict
  
  
  
  
  
  
  
    @unittest.skipIf(torch_device == "mps"       ,     "mish op not supported in MPS"						)
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       UpperCAmelCase_  ,     UpperCAmelCase_      :      List[str]      =					UNetaDModel.from_pretrained(
           "bglick13/hopper-medium-v2-value-function-hor32"       ,     output_loading_info=a_       ,     subfolder="value_function"						)
       self.assertIsNotNone(a_						)
       self.assertEqual(len(vf_loading_info["missing_keys"]						)       ,     0						)
  
       value_function.to(a_						)
       UpperCAmelCase_      :      str      =					value_function(**self.dummy_input						)
  
       assert image is not None, "Make sure output is not None"
  
  
  
  
  
  
  
    @unittest.skipIf(torch_device == "mps"       ,     "mish op not supported in MPS"						)
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       UpperCAmelCase_  ,     UpperCAmelCase_      :      str      =					UNetaDModel.from_pretrained(
           "bglick13/hopper-medium-v2-value-function-hor32"       ,     output_loading_info=a_       ,     subfolder="value_function"						)
       torch.manual_seed(0						)
       if torch.cuda.is_available():
          torch.cuda.manual_seed_all(0						)
  
       UpperCAmelCase_      :      Any      =					value_function.config.in_channels
       UpperCAmelCase_      :      Union[str, Any]      =					14
       UpperCAmelCase_      :      int      =					torch.randn((1, seq_len, num_features)						).permute(
           0       ,     2       ,     1						)  # match original, we can update values and remove
       UpperCAmelCase_      :      str      =					torch.full((num_features,)       ,     0						)
  
       with torch.no_grad():
          UpperCAmelCase_      :      int      =					value_function(a_       ,     a_						).sample
  
       # fmt: off
       UpperCAmelCase_      :      Any      =					torch.tensor([1_65.25] * seq_len						)
       # fmt: on
       self.assertTrue(torch.allclose(a_       ,     a_       ,     rtol=1E-3						)						)
  
  
  
  
  
  
  
    def  UpperCamelCase__      (	self						):
  
       """simple docstring"""
       pass
  
  
  
style_context: 
  """simple docstring"""
  
  
  
  
  
  from string import ascii_uppercase
  
  
  
  
  
  
  
  def 			__a  (	__lowerCamelCase,	__lowerCamelCase,	__lowerCamelCase = False,	__lowerCamelCase = ascii_uppercase						):
     UpperCAmelCase_      :      List[str]      =					keyword.upper()
     UpperCAmelCase_      :      str      =					plaintext.upper()
     UpperCAmelCase_      :      Tuple      =					set(__lowerCamelCase						)
  
     # create a list of unique characters in the keyword - their order matters
     # it determines how we will map plaintext characters to the ciphertext
     UpperCAmelCase_      :      Tuple      =					[]
     for char in keyword:
        if char in alphabet_set and char not in unique_chars:
           unique_chars.append(__lowerCamelCase						)
      # the number of those unique characters will determine the number of rows
     UpperCAmelCase_      :      Union[str, Any]      =					len(__lowerCamelCase						)
  
     # create a shifted version of the alphabet
     UpperCAmelCase_      :      Tuple      =					unique_chars + [
         char for char in alphabet if char not in unique_chars
     ]
  
     # create a modified alphabet by splitting the shifted alphabet into rows
     UpperCAmelCase_      :      List[str]      =					[
         shifted_alphabet[k : k + num_unique_chars_in_keyword]
         for k in range(0,	26,	__lowerCamelCase						)
     ]
  
     # map the alphabet characters to the modified alphabet characters
     # going 'vertically' through the modified alphabet - consider columns first
     UpperCAmelCase_      :      Tuple      =					{}
     UpperCAmelCase_      :      Dict      =					0
     for column in range(__lowerCamelCase						):
        for row in modified_alphabet:
           # if current row (the last one) is too short, break out of loop
           if len(__lowerCamelCase						) <= column:
              break
  
           # map current letter to letter in modified alphabet
           UpperCAmelCase_      :      Tuple      =					row[column]
           letter_index += 1
  
     if verbose:
        print(__lowerCamelCase						)
     # create the encrypted text by mapping the plaintext to the modified alphabet
     return "".join(mapping[char] if char in mapping else char for char in plaintext						)
  
  
  if __name__ == "__main__":
      # example use
      print(mixed_keyword('college', 'UNIVERSITY'))
  
  
  