




'''simple docstring'''

from typing import TYPE_CHECKING

from ..models.auto import AutoModelForVisionaSeq
from ..utils import requires_backends
from .base import PipelineTool


if TYPE_CHECKING:
							from PIL import Image






class 						a				(   _lowerCamelCase     ):
				snake_case_      =		"Salesforce/blip-image-captioning-base"
				snake_case_      =		(
				    "This is a tool that generates a description of an image. It takes an input named `image` which should be the "
				    "image to caption, and returns a text that contains the description in English."
				)
				snake_case_      =		"image_captioner"
				snake_case_      =		AutoModelForVisionaSeq

				snake_case_      =		["image"]
				snake_case_      =		["text"]


				def __init__(		self    :					Union[str, Any]       ,				*lowercase_    :					List[Any]       ,				**lowercase_    :					Optional[Any]					):
									requires_backends(self       ,				['''vision''']					)
									super().__init__(*lowercase_       ,				**lowercase_					)


				def   A_ (		self    :					List[Any]       ,				lowercase_    :					Tuple					):
									return self.pre_processor(images=lowercase_       ,				return_tensors='''pt'''					)


				def   A_ (		self    :					List[str]       ,				lowercase_    :					Union[str, Any]					):
									return self.model.generate(**lowercase_					)


				def   A_ (		self    :					Optional[int]       ,				lowercase_    :					Optional[int]					):
									return self.pre_processor.batch_decode(lowercase_       ,				skip_special_tokens=lowercase_					)[0].strip()







"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowercase__     						=						{"""configuration_ibert""": ["""IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """IBertConfig""", """IBertOnnxConfig"""]}

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			lowercase__     						=						[
			    """IBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
			    """IBertForMaskedLM""",
			    """IBertForMultipleChoice""",
			    """IBertForQuestionAnswering""",
			    """IBertForSequenceClassification""",
			    """IBertForTokenClassification""",
			    """IBertModel""",
			    """IBertPreTrainedModel""",
			]

if TYPE_CHECKING:
			from .configuration_ibert import IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, IBertConfig, IBertOnnxConfig

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_ibert import (
						    IBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
						    IBertForMaskedLM,
						    IBertForMultipleChoice,
						    IBertForQuestionAnswering,
						    IBertForSequenceClassification,
						    IBertForTokenClassification,
						    IBertModel,
						    IBertPreTrainedModel,
						)

else:
			import sys

			lowercase__     						=						_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)