




'''simple docstring'''





import flax.linen as nn
import jax
import jax.numpy as jnp




class  _snake_case		(	nn.Module							):
			lowerCAmelCase_     :      str						       =    42
			lowerCAmelCase_     :      str						       =    jnp.floataa




			def    lowerCAmelCase__				(					self							)				->				Optional[Any]:

										'''simple docstring'''




										snake_case_						=      nn.Conv(
										    self.out_channels				,							kernel_size=(3, 3)				,							strides=(1, 1)				,							padding=((1, 1), (1, 1))				,							dtype=self.dtype				,							)




			def __call__(					self				,							a__							)				->				Optional[int]:

										'''simple docstring'''




										snake_case_					,      snake_case_					,      snake_case_					,      snake_case_						=      hidden_states.shape
										snake_case_						=      jax.image.resize(
										    __lowerCAmelCase				,							shape=(batch, height * 2, width * 2, channels)				,							method="nearest"				,							)
										snake_case_						=      self.conv(__lowerCAmelCase							)
										return hidden_states




class  _snake_case		(	nn.Module							):
			lowerCAmelCase_     :      Any						       =    42
			lowerCAmelCase_     :      Optional[int]						       =    jnp.floataa




			def    lowerCAmelCase__				(					self							)				->				str:

										'''simple docstring'''




										snake_case_						=      nn.Conv(
										    self.out_channels				,							kernel_size=(3, 3)				,							strides=(2, 2)				,							padding=((1, 1), (1, 1))				,							dtype=self.dtype				,							)




			def __call__(					self				,							a__							)				->				Tuple:

										'''simple docstring'''




										snake_case_						=      self.conv(__lowerCAmelCase							)
										return hidden_states




class  _snake_case		(	nn.Module							):
			lowerCAmelCase_     :      List[Any]						       =    42
			lowerCAmelCase_     :      Optional[Any]						       =    None
			lowerCAmelCase_     :      Any						       =    0.0
			lowerCAmelCase_     :      List[Any]						       =    None
			lowerCAmelCase_     :      Optional[Any]						       =    jnp.floataa




			def    lowerCAmelCase__				(					self							)				->				int:

										'''simple docstring'''




										snake_case_						=      self.in_channels if self.out_channels is None else self.out_channels

										snake_case_						=      nn.GroupNorm(num_groups=32				,							epsilon=1e-5							)
										snake_case_						=      nn.Conv(
										    __lowerCAmelCase				,							kernel_size=(3, 3)				,							strides=(1, 1)				,							padding=((1, 1), (1, 1))				,							dtype=self.dtype				,							)

										snake_case_						=      nn.Dense(__lowerCAmelCase				,							dtype=self.dtype							)

										snake_case_						=      nn.GroupNorm(num_groups=32				,							epsilon=1e-5							)
										snake_case_						=      nn.Dropout(self.dropout_prob							)
										snake_case_						=      nn.Conv(
										    __lowerCAmelCase				,							kernel_size=(3, 3)				,							strides=(1, 1)				,							padding=((1, 1), (1, 1))				,							dtype=self.dtype				,							)

										snake_case_						=      self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

										snake_case_						=      None
										if use_nin_shortcut:
																	snake_case_						=      nn.Conv(
																	    __lowerCAmelCase				,							kernel_size=(1, 1)				,							strides=(1, 1)				,							padding="VALID"				,							dtype=self.dtype				,							)




			def __call__(					self				,							a__				,							a__				,							a__=True							)				->				Tuple:

										'''simple docstring'''




										snake_case_						=      hidden_states
										snake_case_						=      self.norma(__lowerCAmelCase							)
										snake_case_						=      nn.swish(__lowerCAmelCase							)
										snake_case_						=      self.conva(__lowerCAmelCase							)

										snake_case_						=      self.time_emb_proj(nn.swish(__lowerCAmelCase							)							)
										snake_case_						=      jnp.expand_dims(jnp.expand_dims(__lowerCAmelCase				,							1							)				,							1							)
										snake_case_						=      hidden_states + temb

										snake_case_						=      self.norma(__lowerCAmelCase							)
										snake_case_						=      nn.swish(__lowerCAmelCase							)
										snake_case_						=      self.dropout(__lowerCAmelCase				,							__lowerCAmelCase							)
										snake_case_						=      self.conva(__lowerCAmelCase							)

										if self.conv_shortcut is not None:
																	snake_case_						=      self.conv_shortcut(__lowerCAmelCase							)

										return hidden_states + residual











import numpy as np

from transformers import Pipeline





def lowerCAmelCase__(__snake_case							)				->      Tuple:







	'''simple docstring'''







	lowerCamelCase__								=		np.max(__snake_case       ,axis=-1       ,keepdims=__snake_case							)
	lowerCamelCase__								=		np.exp(outputs - maxes							)
	return shifted_exp / shifted_exp.sum(axis=-1       ,keepdims=__snake_case							)






class 					__A    (    lowerCAmelCase ):

			'''simple docstring'''







			def 		__lowerCamelCase				(    self       ,  **__lowerCAmelCase							):



				'''simple docstring'''







				lowerCamelCase__								=		{}
				if "second_text" in kwargs:
					lowerCamelCase__								=		kwargs['''second_text''']
				return preprocess_kwargs, {}, {}





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



				'''simple docstring'''







				return self.tokenizer(__lowerCAmelCase       ,  text_pair=__lowerCAmelCase       ,  return_tensors=self.framework							)





			def 		__lowerCamelCase				(    self       ,  __lowerCAmelCase							):



				'''simple docstring'''







				return self.model(**__lowerCAmelCase							)





			def 		__lowerCamelCase				(    self       ,  __lowerCAmelCase							):



				'''simple docstring'''







				lowerCamelCase__								=		model_outputs.logits[0].numpy()
				lowerCamelCase__								=		softmax(__lowerCAmelCase							)

				lowerCamelCase__								=		np.argmax(__lowerCAmelCase							)
				lowerCamelCase__								=		self.model.config.idalabel[best_class]
				lowerCamelCase__								=		probabilities[best_class].item()
				lowerCamelCase__								=		logits.tolist()
				return {"label": label, "score": score, "logits": logits}



