'''simple docstring'''

import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


lowerCAmelCase_ : Union[str, Any]						  =      "\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 ):


   def __UpperCAmelCase       (   self				:	Union[str, Any])      ->					int:
         lowercase_     =      load_tool("text-question-answering")
         self.tool.setup()
         lowercase_     =      load_tool("text-question-answering"   ,		remote=__lowerCAmelCase)


   def __UpperCAmelCase       (   self				:	Dict)      ->					int:
         lowercase_     =      self.tool(__lowerCAmelCase   ,		"What did Hugging Face do in April 2021?")
         self.assertEqual(__lowerCAmelCase   ,		"launched the BigScience Research Workshop")


   def __UpperCAmelCase       (   self				:	int)      ->					Dict:
         lowercase_     =      self.remote_tool(__lowerCAmelCase   ,		"What did Hugging Face do in April 2021?")
         self.assertEqual(__lowerCAmelCase   ,		"launched the BigScience Research Workshop")


   def __UpperCAmelCase       (   self				:	Optional[int])      ->					int:
         lowercase_     =      self.tool(text=__lowerCAmelCase   ,		question="What did Hugging Face do in April 2021?")
         self.assertEqual(__lowerCAmelCase   ,		"launched the BigScience Research Workshop")


   def __UpperCAmelCase       (   self				:	List[Any])      ->					str:
         lowercase_     =      self.remote_tool(text=__lowerCAmelCase   ,		question="What did Hugging Face do in April 2021?")
         self.assertEqual(__lowerCAmelCase   ,		"launched the BigScience Research Workshop")







'''simple docstring'''

from typing import List, Optional, Union

import numpy as np
import PIL.Image

from ...image_processing_utils import BaseImageProcessor, BatchFeature
from ...image_transforms import rescale, resize, to_channel_dimension_format
from ...image_utils import (
    ChannelDimension,
    PILImageResampling,
    get_image_size,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, logging


lowerCAmelCase_ : Any						  =      logging.get_logger(__name__)





class 							lowercase						(						__lowerCamelCase ):
   lowerCamelCase_    					=['pixel_values']


   def __init__(   self				:	Optional[int]   ,		__lowerCAmelCase				:	bool = True   ,		__lowerCAmelCase				:	int = 32   ,		__lowerCAmelCase				:	List[str]=PILImageResampling.BILINEAR   ,		__lowerCAmelCase				:	bool = True   ,		**__lowerCAmelCase				:	Union[str, Any]   ,		)      ->					None:
         lowercase_     =      do_resize
         lowercase_     =      do_rescale
         lowercase_     =      size_divisor
         lowercase_     =      resample
         super().__init__(**__lowerCAmelCase)


   def __UpperCAmelCase       (   self				:	List[str]   ,		__lowerCAmelCase				:	np.ndarray   ,		__lowerCAmelCase				:	int   ,		__lowerCAmelCase				:	Optional[int]   ,		__lowerCAmelCase				:	Optional[ChannelDimension] = None   ,		**__lowerCAmelCase				:	Any)      ->					np.ndarray:
         lowercase_ ,							lowercase_     =      get_image_size(__lowerCAmelCase)
         # Rounds the height and width down to the closest multiple of size_divisor
         lowercase_     =      height // size_divisor * size_divisor
         lowercase_     =      width // size_divisor * size_divisor
         lowercase_     =      resize(__lowerCAmelCase   ,		(new_h, new_w)   ,		resample=__lowerCAmelCase   ,		data_format=__lowerCAmelCase   ,		**__lowerCAmelCase)
         return image


   def __UpperCAmelCase       (   self				:	str   ,		__lowerCAmelCase				:	np.ndarray   ,		__lowerCAmelCase				:	float   ,		__lowerCAmelCase				:	Optional[ChannelDimension] = None   ,		**__lowerCAmelCase				:	int)      ->					np.ndarray:
         return rescale(image=__lowerCAmelCase   ,		scale=__lowerCAmelCase   ,		data_format=__lowerCAmelCase   ,		**__lowerCAmelCase)


   def __UpperCAmelCase       (   self				:	Optional[Any]   ,		__lowerCAmelCase				:	Union["PIL.Image.Image", TensorType, List["PIL.Image.Image"], List[TensorType]]   ,		__lowerCAmelCase				:	Optional[bool] = None   ,		__lowerCAmelCase				:	Optional[int] = None   ,		__lowerCAmelCase				:	str=None   ,		__lowerCAmelCase				:	Optional[bool] = None   ,		__lowerCAmelCase				:	Optional[Union[TensorType, str]] = None   ,		__lowerCAmelCase				:	ChannelDimension = ChannelDimension.FIRST   ,		**__lowerCAmelCase				:	List[str]   ,		)      ->					BatchFeature:
         lowercase_     =      do_resize if do_resize is not None else self.do_resize
         lowercase_     =      do_rescale if do_rescale is not None else self.do_rescale
         lowercase_     =      size_divisor if size_divisor is not None else self.size_divisor
         lowercase_     =      resample if resample is not None else self.resample

         if do_resize and size_divisor is None:
               raise ValueError("size_divisor is required for resizing")

         lowercase_     =      make_list_of_images(__lowerCAmelCase)

         if not valid_images(__lowerCAmelCase):
               raise ValueError("Invalid image(s)")

         # All transformations expect numpy arrays.
         lowercase_     =      [to_numpy_array(__lowerCAmelCase) for img in images]

         if do_resize:
               lowercase_     =      [self.resize(__lowerCAmelCase   ,		size_divisor=__lowerCAmelCase   ,		resample=__lowerCAmelCase) for image in images]

         if do_rescale:
               lowercase_     =      [self.rescale(__lowerCAmelCase   ,		scale=1 / 255) for image in images]

         lowercase_     =      [to_channel_dimension_format(__lowerCAmelCase   ,		__lowerCAmelCase) for image in images]

         lowercase_     =      {"pixel_values": images}
         return BatchFeature(data=__lowerCAmelCase   ,		tensor_type=__lowerCAmelCase)






