





"""simple docstring"""






import unittest

from transformers import is_flax_available
from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow


if is_flax_available():
		import optax
		from flax.training.common_utils import onehot

		from transformers import AutoTokenizer, FlaxMTaForConditionalGeneration
		from transformers.models.ta.modeling_flax_ta import shift_tokens_right




@require_torch
@require_sentencepiece
@require_tokenizers
@require_flax
class 					__lowercase      (      unittest.TestCase				):







					'''simple docstring'''




					@slow
					def 			_lowerCamelCase		(    self  ):
									__a			:    Optional[Any]      							=	FlaxMTaForConditionalGeneration.from_pretrained('''google/mt5-small'''  )
									__a			:    List[Any]      							=	AutoTokenizer.from_pretrained('''google/mt5-small'''  )

									__a			:    List[str]      							=	tokenizer('''Hello there'''						,      return_tensors='''np'''  ).input_ids
									__a			:    List[str]      							=	tokenizer('''Hi I am'''						,      return_tensors='''np'''  ).input_ids

									__a			:    Union[str, Any]      							=	shift_tokens_right(_UpperCAmelCase						,      model.config.pad_token_id						,      model.config.decoder_start_token_id  )

									__a			:    List[Any]      							=	model(_UpperCAmelCase						,      decoder_input_ids=_UpperCAmelCase  ).logits
									__a			:    int      							=	optax.softmax_cross_entropy(_UpperCAmelCase						,      onehot(_UpperCAmelCase						,      logits.shape[-1]  )  ).mean()

									__a			:    List[Any]      							=	-(labels.shape[-1] * loss.item())

									__a			:    List[str]      							=	-8_4.9_1_2_7
									self.assertTrue(abs(mtf_score - EXPECTED_SCORE  ) < 1e-4  )
"""simple docstring"""






import torch

from diffusers import StableDiffusionPipeline


__lowerCAmelCase       :			str   	="""path-to-your-trained-model"""
__lowerCAmelCase       :			int   	=StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to("""cuda""")

__lowerCAmelCase       :			Optional[int]   	="""A photo of sks dog in a bucket"""
__lowerCAmelCase       :			int   	=pipe(prompt, num_inference_steps=5_0, guidance_scale=7.5).images[0]

image.save("""dog-bucket.png""")



