



"""simple docstring"""





import unittest
from pathlib import Path

from transformers import is_vision_available, load_tool
from transformers.testing_utils import get_tests_dir

from .test_tools_common import ToolTesterMixin


if is_vision_available():
  from PIL import Image


class       __lowerCamelCase	(   unittest.TestCase   ,							__lowercase    ):







   def 							A__						(self				):




      '''simple docstring'''




      _lowerCAmelCase					     =		load_tool("""image-captioning"""				)
      self.tool.setup()
      _lowerCAmelCase					     =		load_tool("""image-captioning"""       ,	remote=lowerCamelCase				)







   def 							A__						(self				):




      '''simple docstring'''




      _lowerCAmelCase					     =		Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""				)				) / """000000039769.png"""				)
      _lowerCAmelCase					     =		self.tool(lowerCamelCase				)
      self.assertEqual(lowerCamelCase       ,	"""two cats sleeping on a couch"""				)







   def 							A__						(self				):




      '''simple docstring'''




      _lowerCAmelCase					     =		Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""				)				) / """000000039769.png"""				)
      _lowerCAmelCase					     =		self.remote_tool(lowerCamelCase				)
      self.assertEqual(lowerCamelCase       ,	"""two cats sleeping on a couch"""				)







   def 							A__						(self				):




      '''simple docstring'''




      _lowerCAmelCase					     =		Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""				)				) / """000000039769.png"""				)
      _lowerCAmelCase					     =		self.tool(image=lowerCamelCase				)
      self.assertEqual(lowerCamelCase       ,	"""two cats sleeping on a couch"""				)







   def 							A__						(self				):




      '''simple docstring'''




      _lowerCAmelCase					     =		Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""				)				) / """000000039769.png"""				)
      _lowerCAmelCase					     =		self.remote_tool(image=lowerCamelCase				)
      self.assertEqual(lowerCamelCase       ,	"""two cats sleeping on a couch"""				)




"""simple docstring"""





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
)


SCREAMING_SNAKE_CASE				:     Union[str, Any]          =	{
    '''configuration_align''': [
        '''ALIGN_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''AlignConfig''',
        '''AlignTextConfig''',
        '''AlignVisionConfig''',
    ],
    '''processing_align''': ['''AlignProcessor'''],
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  SCREAMING_SNAKE_CASE				:     Any          =	[
      '''ALIGN_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''AlignModel''',
      '''AlignPreTrainedModel''',
      '''AlignTextModel''',
      '''AlignVisionModel''',
  ]

if TYPE_CHECKING:
  from .configuration_align import (
      ALIGN_PRETRAINED_CONFIG_ARCHIVE_MAP,
      AlignConfig,
      AlignTextConfig,
      AlignVisionConfig,
  )
  from .processing_align import AlignProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_align import (
        ALIGN_PRETRAINED_MODEL_ARCHIVE_LIST,
        AlignModel,
        AlignPreTrainedModel,
        AlignTextModel,
        AlignVisionModel,
    )

else:
  import sys

  SCREAMING_SNAKE_CASE				:     Any          =	_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)