

from typing import List, Optional, Tuple, Union

import torch

from ...utils import randn_tensor
from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput
class 		SCREAMING_SNAKE_CASE__					(		lowerCamelCase__   ):







						"""simple docstring"""




						def __init__(				self , __UpperCamelCase , __UpperCamelCase    )							->	Dict:




									'''simple docstring'''


									super().__init__()
									self.register_modules(unet=a_ , scheduler=a_    )




						@torch.no_grad()
						def __call__(				self , __UpperCamelCase = 1 , __UpperCamelCase = None , __UpperCamelCase = 10_00 , __UpperCamelCase = "pil" , __UpperCamelCase = True , )							->	Union[ImagePipelineOutput, Tuple]:




									'''simple docstring'''


									if isinstance(self.unet.config.sample_size , a_    ):
												__UpperCamelCase    :    Union[str, Any]								=      (
												    batch_size,
												    self.unet.config.in_channels,
												    self.unet.config.sample_size,
												    self.unet.config.sample_size,
												)
									else:
												__UpperCamelCase    :    Dict								=      (batch_size, self.unet.config.in_channels, *self.unet.config.sample_size)

									if self.device.type == "mps":
												# randn does not work reproducibly on mps
												__UpperCamelCase    :    Tuple								=      randn_tensor(a_ , generator=a_    )
												__UpperCamelCase    :    Optional[Any]								=      image.to(self.device    )
									else:
												__UpperCamelCase    :    Dict								=      randn_tensor(a_ , generator=a_ , device=self.device    )

									# set step values
									self.scheduler.set_timesteps(a_    )

									for t in self.progress_bar(self.scheduler.timesteps    ):
												# 1. predict noise model_output
												__UpperCamelCase    :    Optional[Any]								=      self.unet(a_ , a_    ).sample

												# 2. compute previous image: x_t -> x_t-1
												__UpperCamelCase    :    Optional[int]								=      self.scheduler.step(a_ , a_ , a_ , generator=a_    ).prev_sample

									__UpperCamelCase    :    int								=      (image / 2 + 0.5).clamp(0 , 1    )
									__UpperCamelCase    :    List[str]								=      image.cpu().permute(0 , 2 , 3 , 1    ).numpy()
									if output_type == "pil":
												__UpperCamelCase    :    Tuple								=      self.numpy_to_pil(a_    )

									if not return_dict:
												return (image,)

									return ImagePipelineOutput(images=a_    )


import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


lowercase     :       Dict        =       "\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targeted at teenagers.[2] After open-sourcing the model behind the chatbot, the company pivoted to focus on being a platform for machine learning.\n\nIn March 2021, Hugging Face raised $40 million in a Series B funding round.[3]\n\nOn April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model.[4] In 2022, the workshop concluded with the announcement of BLOOM, a multilingual large language model with 176 billion parameters.[5]\n"
class 		SCREAMING_SNAKE_CASE__					(		unittest.TestCase						,	lowerCamelCase__   ):







						"""simple docstring"""




						def __lowerCamelCase					(				self    )							->	Union[str, Any]:




									'''simple docstring'''


									__UpperCamelCase    :    str								=      load_tool("summarization"    )
									self.tool.setup()
									__UpperCamelCase    :    str								=      load_tool("summarization" , remote=__UpperCamelCase    )

						def __lowerCamelCase					(				self    )							->	Optional[int]:




									'''simple docstring'''


									__UpperCamelCase    :    Union[str, Any]								=      self.tool(__UpperCamelCase    )
									self.assertEqual(
									    __UpperCamelCase , "Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM." , )

						def __lowerCamelCase					(				self    )							->	int:




									'''simple docstring'''


									__UpperCamelCase    :    Any								=      self.remote_tool(__UpperCamelCase    )
									self.assertEqual(
									    __UpperCamelCase , "Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM." , )

						def __lowerCamelCase					(				self    )							->	List[Any]:




									'''simple docstring'''


									__UpperCamelCase    :    List[Any]								=      self.tool(text=__UpperCamelCase    )
									self.assertEqual(
									    __UpperCamelCase , "Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM." , )




						def __lowerCamelCase					(				self    )							->	str:




									'''simple docstring'''


									__UpperCamelCase    :    str								=      self.remote_tool(text=__UpperCamelCase    )
									self.assertEqual(
									    __UpperCamelCase , "Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM." , )