






import os
import tempfile
import unittest

import numpy as np

from diffusers.utils import is_flax_available
from diffusers.utils.testing_utils import require_flax, slow


if is_flax_available():
 import jax
 import jax.numpy as jnp
 from flax.jax_utils import replicate
 from flax.training.common_utils import shard

 from diffusers import FlaxDDIMScheduler, FlaxDiffusionPipeline, FlaxStableDiffusionPipeline



@require_flax
class 							_UpperCamelCase			(unittest.TestCase			):


      def  __UpperCAmelCase		(	self	)->	int:
           with tempfile.TemporaryDirectory() as tmpdirname:
                # pipeline has Flax weights
                __lowerCAmelCase								=					FlaxDiffusionPipeline.from_pretrained(
                    "hf-internal-testing/tiny-stable-diffusion-pipe"					,						safety_checker=__UpperCamelCase					,						cache_dir=__UpperCamelCase	)

                __lowerCAmelCase								=					[t[-1] for t in os.walk(os.path.join(__UpperCamelCase					,						os.listdir(__UpperCamelCase	)[0]					,						"snapshots"	)	)]
                __lowerCAmelCase								=					[item for sublist in all_root_files for item in sublist]

                # None of the downloaded files should be a PyTorch file even if we have some here:
                # https://huggingface.co/hf-internal-testing/tiny-stable-diffusion-pipe/blob/main/unet/diffusion_pytorch_model.bin
                assert not any(f.endswith(".bin"	) for f in files	)



@slow
@require_flax
class 							_UpperCamelCase			(unittest.TestCase			):


      def  __UpperCAmelCase		(	self	)->	int:
           __lowerCAmelCase			, __lowerCAmelCase								=					FlaxStableDiffusionPipeline.from_pretrained(
               "hf-internal-testing/tiny-stable-diffusion-pipe"					,						safety_checker=__UpperCamelCase	)

           __lowerCAmelCase								=					(
               "A cinematic film still of Morgan Freeman starring as Jimi Hendrix, portrait, 40mm lens, shallow depth of"
               " field, close up, split lighting, cinematic"
           )

           __lowerCAmelCase								=					jax.random.PRNGKey(0	)
           __lowerCAmelCase								=					4

           __lowerCAmelCase								=					jax.device_count()
           __lowerCAmelCase								=					num_samples * [prompt]
           __lowerCAmelCase								=					pipeline.prepare_inputs(__UpperCamelCase	)

           # shard inputs and rng
           __lowerCAmelCase								=					replicate(__UpperCamelCase	)
           __lowerCAmelCase								=					jax.random.split(__UpperCamelCase					,						__UpperCamelCase	)
           __lowerCAmelCase								=					shard(__UpperCamelCase	)

           __lowerCAmelCase								=					pipeline(__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase					,						jit=__UpperCamelCase	).images

           assert images.shape == (num_samples, 1, 6_4, 6_4, 3)
           if jax.device_count() == 8:
                assert np.abs(np.abs(images[0, 0, :2, :2, -2:]					,						dtype=np.floataa	).sum() - 4.1_5_1_4_7_4_5	) < 1e-3
                assert np.abs(np.abs(__UpperCamelCase					,						dtype=np.floataa	).sum() - 4_9_9_4_7.8_7_5	) < 5e-1

           __lowerCAmelCase								=					pipeline.numpy_to_pil(np.asarray(images.reshape((num_samples,) + images.shape[-3:]	)	)	)
           assert len(__UpperCamelCase	) == num_samples


      def  __UpperCAmelCase		(	self	)->	int:
           __lowerCAmelCase			, __lowerCAmelCase								=					FlaxStableDiffusionPipeline.from_pretrained(
               "CompVis/stable-diffusion-v1-4"					,						revision="flax"					,						safety_checker=__UpperCamelCase	)

           __lowerCAmelCase								=					(
               "A cinematic film still of Morgan Freeman starring as Jimi Hendrix, portrait, 40mm lens, shallow depth of"
               " field, close up, split lighting, cinematic"
           )

           __lowerCAmelCase								=					jax.random.PRNGKey(0	)
           __lowerCAmelCase								=					5_0

           __lowerCAmelCase								=					jax.device_count()
           __lowerCAmelCase								=					num_samples * [prompt]
           __lowerCAmelCase								=					pipeline.prepare_inputs(__UpperCamelCase	)

           # shard inputs and rng
           __lowerCAmelCase								=					replicate(__UpperCamelCase	)
           __lowerCAmelCase								=					jax.random.split(__UpperCamelCase					,						__UpperCamelCase	)
           __lowerCAmelCase								=					shard(__UpperCamelCase	)

           __lowerCAmelCase								=					pipeline(__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase					,						jit=__UpperCamelCase	).images

           assert images.shape == (num_samples, 1, 5_1_2, 5_1_2, 3)
           if jax.device_count() == 8:
                assert np.abs((np.abs(images[0, 0, :2, :2, -2:]					,						dtype=np.floataa	).sum() - 0.0_5_6_5_2_4_0_1)	) < 1e-3
                assert np.abs((np.abs(__UpperCamelCase					,						dtype=np.floataa	).sum() - 2_3_8_3_8_0_8.2)	) < 5e-1


      def  __UpperCAmelCase		(	self	)->	str:
           __lowerCAmelCase			, __lowerCAmelCase								=					FlaxStableDiffusionPipeline.from_pretrained(
               "CompVis/stable-diffusion-v1-4"					,						revision="bf16"					,						dtype=jnp.bfloataa					,						safety_checker=__UpperCamelCase	)

           __lowerCAmelCase								=					(
               "A cinematic film still of Morgan Freeman starring as Jimi Hendrix, portrait, 40mm lens, shallow depth of"
               " field, close up, split lighting, cinematic"
           )

           __lowerCAmelCase								=					jax.random.PRNGKey(0	)
           __lowerCAmelCase								=					5_0

           __lowerCAmelCase								=					jax.device_count()
           __lowerCAmelCase								=					num_samples * [prompt]
           __lowerCAmelCase								=					pipeline.prepare_inputs(__UpperCamelCase	)

           # shard inputs and rng
           __lowerCAmelCase								=					replicate(__UpperCamelCase	)
           __lowerCAmelCase								=					jax.random.split(__UpperCamelCase					,						__UpperCamelCase	)
           __lowerCAmelCase								=					shard(__UpperCamelCase	)

           __lowerCAmelCase								=					pipeline(__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase					,						jit=__UpperCamelCase	).images

           assert images.shape == (num_samples, 1, 5_1_2, 5_1_2, 3)
           if jax.device_count() == 8:
                assert np.abs((np.abs(images[0, 0, :2, :2, -2:]					,						dtype=np.floataa	).sum() - 0.0_4_0_0_3_9_0_6)	) < 1e-3
                assert np.abs((np.abs(__UpperCamelCase					,						dtype=np.floataa	).sum() - 2_3_7_3_5_1_6.7_5)	) < 5e-1


      def  __UpperCAmelCase		(	self	)->	Optional[Any]:
           __lowerCAmelCase			, __lowerCAmelCase								=					FlaxStableDiffusionPipeline.from_pretrained(
               "CompVis/stable-diffusion-v1-4"					,						revision="bf16"					,						dtype=jnp.bfloataa	)

           __lowerCAmelCase								=					(
               "A cinematic film still of Morgan Freeman starring as Jimi Hendrix, portrait, 40mm lens, shallow depth of"
               " field, close up, split lighting, cinematic"
           )

           __lowerCAmelCase								=					jax.random.PRNGKey(0	)
           __lowerCAmelCase								=					5_0

           __lowerCAmelCase								=					jax.device_count()
           __lowerCAmelCase								=					num_samples * [prompt]
           __lowerCAmelCase								=					pipeline.prepare_inputs(__UpperCamelCase	)

           # shard inputs and rng
           __lowerCAmelCase								=					replicate(__UpperCamelCase	)
           __lowerCAmelCase								=					jax.random.split(__UpperCamelCase					,						__UpperCamelCase	)
           __lowerCAmelCase								=					shard(__UpperCamelCase	)

           __lowerCAmelCase								=					pipeline(__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase					,						jit=__UpperCamelCase	).images

           assert images.shape == (num_samples, 1, 5_1_2, 5_1_2, 3)
           if jax.device_count() == 8:
                assert np.abs((np.abs(images[0, 0, :2, :2, -2:]					,						dtype=np.floataa	).sum() - 0.0_4_0_0_3_9_0_6)	) < 1e-3
                assert np.abs((np.abs(__UpperCamelCase					,						dtype=np.floataa	).sum() - 2_3_7_3_5_1_6.7_5)	) < 5e-1


      def  __UpperCAmelCase		(	self	)->	Optional[int]:
           __lowerCAmelCase								=					FlaxDDIMScheduler(
               beta_start=0.0_0_0_8_5					,						beta_end=0.0_1_2					,						beta_schedule="scaled_linear"					,						set_alpha_to_one=__UpperCamelCase					,						steps_offset=1					,						)

           __lowerCAmelCase			, __lowerCAmelCase								=					FlaxStableDiffusionPipeline.from_pretrained(
               "CompVis/stable-diffusion-v1-4"					,						revision="bf16"					,						dtype=jnp.bfloataa					,						scheduler=__UpperCamelCase					,						safety_checker=__UpperCamelCase					,						)
           __lowerCAmelCase								=					scheduler.create_state()

           __lowerCAmelCase								=					scheduler_state

           __lowerCAmelCase								=					(
               "A cinematic film still of Morgan Freeman starring as Jimi Hendrix, portrait, 40mm lens, shallow depth of"
               " field, close up, split lighting, cinematic"
           )

           __lowerCAmelCase								=					jax.random.PRNGKey(0	)
           __lowerCAmelCase								=					5_0

           __lowerCAmelCase								=					jax.device_count()
           __lowerCAmelCase								=					num_samples * [prompt]
           __lowerCAmelCase								=					pipeline.prepare_inputs(__UpperCamelCase	)

           # shard inputs and rng
           __lowerCAmelCase								=					replicate(__UpperCamelCase	)
           __lowerCAmelCase								=					jax.random.split(__UpperCamelCase					,						__UpperCamelCase	)
           __lowerCAmelCase								=					shard(__UpperCamelCase	)

           __lowerCAmelCase								=					pipeline(__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase					,						jit=__UpperCamelCase	).images

           assert images.shape == (num_samples, 1, 5_1_2, 5_1_2, 3)
           if jax.device_count() == 8:
                assert np.abs((np.abs(images[0, 0, :2, :2, -2:]					,						dtype=np.floataa	).sum() - 0.0_4_5_0_4_3_9_4_5)	) < 1e-3
                assert np.abs((np.abs(__UpperCamelCase					,						dtype=np.floataa	).sum() - 2_3_4_7_6_9_3.5)	) < 5e-1


      def  __UpperCAmelCase		(	self	)->	Optional[int]:
           __lowerCAmelCase								=					(
               "A cinematic film still of Morgan Freeman starring as Jimi Hendrix, portrait, 40mm lens, shallow depth of"
               " field, close up, split lighting, cinematic"
           )

           __lowerCAmelCase								=					jax.device_count()
           __lowerCAmelCase								=					num_samples * [prompt]
           __lowerCAmelCase								=					jax.random.split(jax.random.PRNGKey(0	)					,						__UpperCamelCase	)

           __lowerCAmelCase			, __lowerCAmelCase								=					FlaxStableDiffusionPipeline.from_pretrained(
               "CompVis/stable-diffusion-v1-4"					,						revision="bf16"					,						dtype=jnp.bfloataa					,						safety_checker=__UpperCamelCase					,						)

           __lowerCAmelCase								=					replicate(__UpperCamelCase	)
           __lowerCAmelCase								=					pipeline.prepare_inputs(__UpperCamelCase	)
           __lowerCAmelCase								=					shard(__UpperCamelCase	)
           __lowerCAmelCase								=					pipeline(__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase					,						jit=__UpperCamelCase	).images
           assert images.shape == (num_samples, 1, 5_1_2, 5_1_2, 3)
           __lowerCAmelCase								=					images[2, 0, 2_5_6, 1_0:1_7, 1]

           # With memory efficient attention
           __lowerCAmelCase			, __lowerCAmelCase								=					FlaxStableDiffusionPipeline.from_pretrained(
               "CompVis/stable-diffusion-v1-4"					,						revision="bf16"					,						dtype=jnp.bfloataa					,						safety_checker=__UpperCamelCase					,						use_memory_efficient_attention=__UpperCamelCase					,						)

           __lowerCAmelCase								=					replicate(__UpperCamelCase	)
           __lowerCAmelCase								=					pipeline.prepare_inputs(__UpperCamelCase	)
           __lowerCAmelCase								=					shard(__UpperCamelCase	)
           __lowerCAmelCase								=					pipeline(__UpperCamelCase					,						__UpperCamelCase					,						__UpperCamelCase					,						jit=__UpperCamelCase	).images
           assert images_eff.shape == (num_samples, 1, 5_1_2, 5_1_2, 3)
           __lowerCAmelCase								=					images[2, 0, 2_5_6, 1_0:1_7, 1]

           # I checked the results visually and they are very similar. However, I saw that the max diff is `1` and the `sum`
           # over the 8 images is exactly `256`, which is very suspicious. Testing a random slice for now.
           assert abs(slice_eff - slice	).max() < 1e-2














import enum
import warnings

from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING
from ..utils import add_end_docstrings, is_tf_available
from .base import PIPELINE_INIT_ARGS, Pipeline


if is_tf_available():
 import tensorflow as tf



class 							_UpperCamelCase			(enum.Enum			):
      snake_case_  =							0
      snake_case_  =							1
      snake_case_  =							2



@add_end_docstrings(a_			)
class 							_UpperCamelCase			(a_			):
      snake_case_  =							"""
    In 1991, the remains of Russian Tsar Nicholas II and his family (except for Alexei and Maria) are discovered. The
    voice of Nicholas's young son, Tsarevich Alexei Nikolaevich, narrates the remainder of the story. 1883 Western
    Siberia, a young Grigori Rasputin is asked by his father and a group of men to perform magic. Rasputin has a vision
    and denounces one of the men as a horse thief. Although his father initially slaps him for making such an
    accusation, Rasputin watches as the man is chased outside and beaten. Twenty years later, Rasputin sees a vision of
    the Virgin Mary, prompting him to become a priest. Rasputin quickly becomes famous, with people, even a bishop,
    begging for his blessing. <eod> </s> <eos>
    """


      def __init__(	self					,						*__UpperCamelCase					,						**__UpperCamelCase	)->	Optional[int]:
           super().__init__(*__UpperCamelCase					,						**__UpperCamelCase	)
           self.check_model_type(
               TF_MODEL_FOR_CAUSAL_LM_MAPPING if self.framework == "tf" else MODEL_FOR_CAUSAL_LM_MAPPING	)
           if "prefix" not in self._preprocess_params:
                # This is very specific. The logic is quite complex and needs to be done
                # as a "default".
                # It also defines both some preprocess_kwargs and generate_kwargs
                # which is why we cannot put them in their respective methods.
                __lowerCAmelCase								=					None
                if self.model.config.prefix is not None:
                     __lowerCAmelCase								=					self.model.config.prefix
                if prefix is None and self.model.__class__.__name__ in [
                    "XLNetLMHeadModel",
                    "TransfoXLLMHeadModel",
                    "TFXLNetLMHeadModel",
                    "TFTransfoXLLMHeadModel",
                ]:
                     # For XLNet and TransformerXL we add an article to the prompt to give more state to the model.
                     __lowerCAmelCase								=					self.XL_PREFIX
                if prefix is not None:
                     # Recalculate some generate_kwargs linked to prefix.
                     __lowerCAmelCase			, __lowerCAmelCase			, __lowerCAmelCase								=					self._sanitize_parameters(prefix=__UpperCamelCase					,						**self._forward_params	)
                     __lowerCAmelCase								=					{**self._preprocess_params, **preprocess_params}
                     __lowerCAmelCase								=					{**self._forward_params, **forward_params}


      def  __UpperCAmelCase		(	self					,						__UpperCamelCase=None					,						__UpperCamelCase=None					,						__UpperCamelCase=None					,						__UpperCamelCase=None					,						__UpperCamelCase=None					,						__UpperCamelCase=None					,						__UpperCamelCase=None					,						__UpperCamelCase=None					,						**__UpperCamelCase					,						)->	int:
           __lowerCAmelCase								=					{}
           if prefix is not None:
                __lowerCAmelCase								=					prefix
           if prefix:
                __lowerCAmelCase								=					self.tokenizer(
                    __UpperCamelCase					,						padding=__UpperCamelCase					,						add_special_tokens=__UpperCamelCase					,						return_tensors=self.framework	)
                __lowerCAmelCase								=					prefix_inputs["input_ids"].shape[-1]

           if handle_long_generation is not None:
                if handle_long_generation not in {"hole"}:
                     raise ValueError(
                         F"""{handle_long_generation} is not a valid value for `handle_long_generation` parameter expected"""
                         " [None, 'hole']"	)
                __lowerCAmelCase								=					handle_long_generation

           preprocess_params.update(__UpperCamelCase	)
           __lowerCAmelCase								=					generate_kwargs

           __lowerCAmelCase								=					{}
           if return_full_text is not None and return_type is None:
                if return_text is not None:
                     raise ValueError("`return_text` is mutually exclusive with `return_full_text`"	)
                if return_tensors is not None:
                     raise ValueError("`return_full_text` is mutually exclusive with `return_tensors`"	)
                __lowerCAmelCase								=					ReturnType.FULL_TEXT if return_full_text else ReturnType.NEW_TEXT
           if return_tensors is not None and return_type is None:
                if return_text is not None:
                     raise ValueError("`return_text` is mutually exclusive with `return_tensors`"	)
                __lowerCAmelCase								=					ReturnType.TENSORS
           if return_type is not None:
                __lowerCAmelCase								=					return_type
           if clean_up_tokenization_spaces is not None:
                __lowerCAmelCase								=					clean_up_tokenization_spaces

           if stop_sequence is not None:
                __lowerCAmelCase								=					self.tokenizer.encode(__UpperCamelCase					,						add_special_tokens=__UpperCamelCase	)
                if len(__UpperCamelCase	) > 1:
                     warnings.warn(
                         "Stopping on a multiple token sequence is not yet supported on transformers. The first token of"
                         " the stop sequence will be used as the stop sequence string in the interim."	)
                __lowerCAmelCase								=					stop_sequence_ids[0]

           return preprocess_params, forward_params, postprocess_params


      def  __UpperCAmelCase		(	self					,						*__UpperCamelCase					,						**__UpperCamelCase	)->	List[str]:
           # Parse arguments
           if self.model.__class__.__name__ in ["TransfoXLLMHeadModel"]:
                kwargs.update({"add_space_before_punct_symbol": True}	)

           return super()._parse_and_tokenize(*__UpperCamelCase					,						**__UpperCamelCase	)


      def __call__(	self					,						__UpperCamelCase					,						**__UpperCamelCase	)->	List[Any]:
           return super().__call__(__UpperCamelCase					,						**__UpperCamelCase	)


      def  __UpperCAmelCase		(	self					,						__UpperCamelCase					,						__UpperCamelCase=""					,						__UpperCamelCase=None					,						**__UpperCamelCase	)->	int:
           __lowerCAmelCase								=					self.tokenizer(
               prefix + prompt_text					,						padding=__UpperCamelCase					,						add_special_tokens=__UpperCamelCase					,						return_tensors=self.framework	)
           __lowerCAmelCase								=					prompt_text

           if handle_long_generation == "hole":
                __lowerCAmelCase								=					inputs["input_ids"].shape[-1]
                if "max_new_tokens" in generate_kwargs:
                     __lowerCAmelCase								=					generate_kwargs["max_new_tokens"]
                else:
                     __lowerCAmelCase								=					generate_kwargs.get("max_length"					,						self.model.config.max_length	) - cur_len
                     if new_tokens < 0:
                          raise ValueError("We cannot infer how many new tokens are expected"	)
                if cur_len + new_tokens > self.tokenizer.model_max_length:
                     __lowerCAmelCase								=					self.tokenizer.model_max_length - new_tokens
                     if keep_length <= 0:
                          raise ValueError(
                              "We cannot use `hole` to handle this generation the number of desired tokens exceeds the"
                              " models max length"	)

                     __lowerCAmelCase								=					inputs["input_ids"][:, -keep_length:]
                     if "attention_mask" in inputs:
                          __lowerCAmelCase								=					inputs["attention_mask"][:, -keep_length:]

           return inputs


      def  __UpperCAmelCase		(	self					,						__UpperCamelCase					,						**__UpperCamelCase	)->	Optional[Any]:
           __lowerCAmelCase								=					model_inputs["input_ids"]
           __lowerCAmelCase								=					model_inputs.get("attention_mask"					,						__UpperCamelCase	)
           # Allow empty prompts
           if input_ids.shape[1] == 0:
                __lowerCAmelCase								=					None
                __lowerCAmelCase								=					None
                __lowerCAmelCase								=					1
           else:
                __lowerCAmelCase								=					input_ids.shape[0]
           __lowerCAmelCase								=					model_inputs.pop("prompt_text"	)

           # If there is a prefix, we may need to adjust the generation length. Do so without permanently modifying
           # generate_kwargs, as some of the parameterization may come from the initialization of the pipeline.
           __lowerCAmelCase								=					generate_kwargs.pop("prefix_length"					,						0	)
           if prefix_length > 0:
                __lowerCAmelCase								=					"max_new_tokens" in generate_kwargs or (
                    "generation_config" in generate_kwargs
                    and generate_kwargs["generation_config"].max_new_tokens is not None
                )
                if not has_max_new_tokens:
                     __lowerCAmelCase								=					generate_kwargs.get("max_length"	) or self.model.config.max_length
                     generate_kwargs["max_length"] += prefix_length
                __lowerCAmelCase								=					"min_new_tokens" in generate_kwargs or (
                    "generation_config" in generate_kwargs
                    and generate_kwargs["generation_config"].min_new_tokens is not None
                )
                if not has_min_new_tokens and "min_length" in generate_kwargs:
                     generate_kwargs["min_length"] += prefix_length

        # BS x SL
           __lowerCAmelCase								=					self.model.generate(input_ids=__UpperCamelCase					,						attention_mask=__UpperCamelCase					,						**__UpperCamelCase	)
           __lowerCAmelCase								=					generated_sequence.shape[0]
           if self.framework == "pt":
                __lowerCAmelCase								=					generated_sequence.reshape(__UpperCamelCase					,						out_b // in_b					,						*generated_sequence.shape[1:]	)
           elif self.framework == "tf":
                __lowerCAmelCase								=					tf.reshape(__UpperCamelCase					,						(in_b, out_b // in_b, *generated_sequence.shape[1:])	)
           return {"generated_sequence": generated_sequence, "input_ids": input_ids, "prompt_text": prompt_text}


      def  __UpperCAmelCase		(	self					,						__UpperCamelCase					,						__UpperCamelCase=ReturnType.FULL_TEXT					,						__UpperCamelCase=True	)->	Any:
           __lowerCAmelCase								=					model_outputs["generated_sequence"][0]
           __lowerCAmelCase								=					model_outputs["input_ids"]
           __lowerCAmelCase								=					model_outputs["prompt_text"]
           __lowerCAmelCase								=					generated_sequence.numpy().tolist()
           __lowerCAmelCase								=					[]
           for sequence in generated_sequence:
                if return_type == ReturnType.TENSORS:
                     __lowerCAmelCase								=					{"generated_token_ids": sequence}
                elif return_type in {ReturnType.NEW_TEXT, ReturnType.FULL_TEXT}:
                     # Decode text
                     __lowerCAmelCase								=					self.tokenizer.decode(
                         __UpperCamelCase					,						skip_special_tokens=__UpperCamelCase					,						clean_up_tokenization_spaces=__UpperCamelCase					,						)

                     # Remove PADDING prompt of the sequence if XLNet or Transfo-XL model is used
                     if input_ids is None:
                          __lowerCAmelCase								=					0
                     else:
                          __lowerCAmelCase								=					len(
                              self.tokenizer.decode(
                                  input_ids[0]					,						skip_special_tokens=__UpperCamelCase					,						clean_up_tokenization_spaces=__UpperCamelCase					,						)	)

                     if return_type == ReturnType.FULL_TEXT:
                          __lowerCAmelCase								=					prompt_text + text[prompt_length:]
                     else:
                          __lowerCAmelCase								=					text[prompt_length:]

                     __lowerCAmelCase								=					{"generated_text": all_text}
                records.append(__UpperCamelCase	)

           return records






