

import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
					import torch

if is_vision_available():
					from PIL import Image

					from transformers import EfficientNetImageProcessor
class 		SCREAMING_SNAKE_CASE__					(		unittest.TestCase   ):







						"""simple docstring"""




						def __init__(				self , __UpperCamelCase , __UpperCamelCase=13 , __UpperCamelCase=3 , __UpperCamelCase=18 , __UpperCamelCase=30 , __UpperCamelCase=4_00 , __UpperCamelCase=True , __UpperCamelCase=None , __UpperCamelCase=True , __UpperCamelCase=[0.5, 0.5, 0.5] , __UpperCamelCase=[0.5, 0.5, 0.5] , )							->	int:




									'''simple docstring'''


									__UpperCamelCase    :    Dict								=      size if size is not None else {"height": 18, "width": 18}
									__UpperCamelCase    :    List[Any]								=      parent
									__UpperCamelCase    :    Optional[int]								=      batch_size
									__UpperCamelCase    :    List[Any]								=      num_channels
									__UpperCamelCase    :    List[Any]								=      image_size
									__UpperCamelCase    :    str								=      min_resolution
									__UpperCamelCase    :    Optional[int]								=      max_resolution
									__UpperCamelCase    :    Optional[int]								=      do_resize
									__UpperCamelCase    :    List[str]								=      size
									__UpperCamelCase    :    List[Any]								=      do_normalize
									__UpperCamelCase    :    Dict								=      image_mean
									__UpperCamelCase    :    List[str]								=      image_std




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




									'''simple docstring'''


									return {
									    "image_mean": self.image_mean,
									    "image_std": self.image_std,
									    "do_normalize": self.do_normalize,
									    "do_resize": self.do_resize,
									    "size": self.size,
									}







@require_torch
@require_vision
class 		SCREAMING_SNAKE_CASE__					(		lowerCamelCase__						,	unittest.TestCase   ):







						"""simple docstring"""




						lowercase  :				int											=							EfficientNetImageProcessor if is_vision_available() else None

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




									'''simple docstring'''


									__UpperCamelCase    :    int								=      EfficientNetImageProcessorTester(self    )

						@property
						def __lowerCamelCase					(				self    )							->	str:




									'''simple docstring'''


									return self.image_processor_tester.prepare_image_processor_dict()

						def __lowerCamelCase					(				self    )							->	Any:




									'''simple docstring'''


									__UpperCamelCase    :    List[Any]								=      self.image_processing_class(**self.image_processor_dict    )
									self.assertTrue(hasattr(__UpperCamelCase , "image_mean"    )    )
									self.assertTrue(hasattr(__UpperCamelCase , "image_std"    )    )
									self.assertTrue(hasattr(__UpperCamelCase , "do_normalize"    )    )
									self.assertTrue(hasattr(__UpperCamelCase , "do_resize"    )    )
									self.assertTrue(hasattr(__UpperCamelCase , "size"    )    )

						def __lowerCamelCase					(				self    )							->	int:




									'''simple docstring'''


									__UpperCamelCase    :    Tuple								=      self.image_processing_class.from_dict(self.image_processor_dict    )
									self.assertEqual(image_processor.size , {"height": 18, "width": 18}    )

									__UpperCamelCase    :    Any								=      self.image_processing_class.from_dict(self.image_processor_dict , size=42    )
									self.assertEqual(image_processor.size , {"height": 42, "width": 42}    )

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




									'''simple docstring'''


									__UpperCamelCase    :    Union[str, Any]								=      self.image_processing_class(**self.image_processor_dict    )
									# create random PIL images
									__UpperCamelCase    :    Tuple								=      prepare_image_inputs(self.image_processor_tester , equal_resolution=__UpperCamelCase    )
									for image in image_inputs:
												self.assertIsInstance(__UpperCamelCase , Image.Image    )

									# Test not batched input
									__UpperCamelCase    :    Tuple								=      image_processing(image_inputs[0] , return_tensors="pt"    ).pixel_values
									self.assertEqual(
									    encoded_images.shape , (
									        1,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size["height"],
									        self.image_processor_tester.size["width"],
									    ) , )

									# Test batched
									__UpperCamelCase    :    Optional[int]								=      image_processing(__UpperCamelCase , return_tensors="pt"    ).pixel_values
									self.assertEqual(
									    encoded_images.shape , (
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size["height"],
									        self.image_processor_tester.size["width"],
									    ) , )

						def __lowerCamelCase					(				self    )							->	Any:




									'''simple docstring'''


									__UpperCamelCase    :    List[str]								=      self.image_processing_class(**self.image_processor_dict    )
									# create random numpy tensors
									__UpperCamelCase    :    Union[str, Any]								=      prepare_image_inputs(self.image_processor_tester , equal_resolution=__UpperCamelCase , numpify=__UpperCamelCase    )
									for image in image_inputs:
												self.assertIsInstance(__UpperCamelCase , np.ndarray    )

									# Test not batched input
									__UpperCamelCase    :    List[str]								=      image_processing(image_inputs[0] , return_tensors="pt"    ).pixel_values
									self.assertEqual(
									    encoded_images.shape , (
									        1,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size["height"],
									        self.image_processor_tester.size["width"],
									    ) , )

									# Test batched
									__UpperCamelCase    :    Any								=      image_processing(__UpperCamelCase , return_tensors="pt"    ).pixel_values
									self.assertEqual(
									    encoded_images.shape , (
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size["height"],
									        self.image_processor_tester.size["width"],
									    ) , )




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




									'''simple docstring'''


									__UpperCamelCase    :    List[str]								=      self.image_processing_class(**self.image_processor_dict    )
									# create random PyTorch tensors
									__UpperCamelCase    :    int								=      prepare_image_inputs(self.image_processor_tester , equal_resolution=__UpperCamelCase , torchify=__UpperCamelCase    )
									for image in image_inputs:
												self.assertIsInstance(__UpperCamelCase , torch.Tensor    )

									# Test not batched input
									__UpperCamelCase    :    Union[str, Any]								=      image_processing(image_inputs[0] , return_tensors="pt"    ).pixel_values
									self.assertEqual(
									    encoded_images.shape , (
									        1,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size["height"],
									        self.image_processor_tester.size["width"],
									    ) , )

									# Test batched
									__UpperCamelCase    :    List[str]								=      image_processing(__UpperCamelCase , return_tensors="pt"    ).pixel_values
									self.assertEqual(
									    encoded_images.shape , (
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size["height"],
									        self.image_processor_tester.size["width"],
									    ) , )


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." , )