
"""simple docstring"""





from typing import Optional

from torch import nn

from .transformer_ad import TransformeraDModel, TransformeraDModelOutput






class        _UpperCAmelCase(       nn.Module      ):



		def __init__(   self							,						__a = 16							,						__a = 88							,						__a = None							,						__a = 1							,						__a = 0.0							,						__a = 32							,						__a = None							,						__a = False							,						__a = None							,						__a = None							,						__a = "geglu"							,						__a = None							,						)			->			str:






							'''simple docstring'''
							super().__init__()
							_UpperCamelCase									=    nn.ModuleList(
							    [
							        TransformeraDModel(
							            num_attention_heads=__a							,						attention_head_dim=__a							,						in_channels=__a							,						num_layers=__a							,						dropout=__a							,						norm_num_groups=__a							,						cross_attention_dim=__a							,						attention_bias=__a							,						sample_size=__a							,						num_vector_embeds=__a							,						activation_fn=__a							,						num_embeds_ada_norm=__a							,						)
							        for _ in range(2)
							    ])

							# Variables that can be set by a pipeline:

							# The ratio of transformer1 to transformer2's output states to be combined during inference
							_UpperCamelCase									=    0.5

							# The shape of `encoder_hidden_states` is expected to be
							# `(batch_size, condition_lengths[0]+condition_lengths[1], num_features)`
							_UpperCamelCase									=    [77, 2_57]

							# Which transformer to use to encode which condition.
							# E.g. `(1, 0)` means that we'll use `transformers[1](conditions[0])` and `transformers[0](conditions[1])`
							_UpperCamelCase									=    [1, 0]




		def 		UpperCAmelCase				(   self							,						__a							,						__a							,						__a=None							,						__a=None							,						__a=None							,						__a = True							,						)			->			Dict:






							'''simple docstring'''
							_UpperCamelCase									=    hidden_states

							_UpperCamelCase									=    []
							_UpperCamelCase									=    0
							# attention_mask is not used yet
							for i in range(2):
												# for each of the two transformers, pass the corresponding condition tokens
												_UpperCamelCase									=    encoder_hidden_states[:, tokens_start : tokens_start + self.condition_lengths[i]]
												_UpperCamelCase									=    self.transformer_index_for_condition[i]
												_UpperCamelCase									=    self.transformers[transformer_index](
												    __a							,						encoder_hidden_states=__a							,						timestep=__a							,						cross_attention_kwargs=__a							,						return_dict=__a							,						)[0]
												encoded_states.append(encoded_state - input_states)
												tokens_start += self.condition_lengths[i]

							_UpperCamelCase									=    encoded_states[0] * self.mix_ratio + encoded_states[1] * (1 - self.mix_ratio)
							_UpperCamelCase									=    output_states + input_states

							if not return_dict:
												return (output_states,)

							return TransformeraDModelOutput(sample=__a)








"""simple docstring"""





from __future__ import annotations

from functools import lru_cache
from math import ceil

_a								=						100

_a								=						set(range(3, NUM_PRIMES, 2))
primes.add(2)
_a								=						42

for prime in range(3, ceil(NUM_PRIMES**0.5), 2):
				if prime not in primes:
								continue
				primes.difference_update(set(range(prime * prime, NUM_PRIMES, prime)))



@lru_cache(maxsize=1_00      )
def  lowerCamelCase__						(     __snake_case      )				->						set[int]:


					"""simple docstring"""





					if number_to_partition < 0:
										return set()
					elif number_to_partition == 0:
										return {1}

					_UpperCamelCase									=    set()
					_UpperCamelCase									=    42
					_UpperCamelCase									=    42

					for prime in primes:
										if prime > number_to_partition:
															continue
										for sub in partition(number_to_partition - prime      ):
															ret.add(sub * prime      )

					return ret



def  lowerCamelCase__						(     __snake_case = 50_00      )				->						int | None:


					"""simple docstring"""





					for number_to_partition in range(1,	__snake_case      ):
										if len(partition(__snake_case      )      ) > number_unique_partitions:
															return number_to_partition
					return None


if __name__ == "__main__":
				print(F"""{solution() = }""")






