
"""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 		UpperCAmelCase_	(unittest.TestCase  , lowerCamelCase_						):
 """simple docstring"""




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



      """simple docstring"""

      UpperCAmelCase_						:    Any    					=  load_tool("""image-captioning""" )
      self.tool.setup()
      UpperCAmelCase_						:    Tuple    					=  load_tool("""image-captioning"""     ,   remote=a_ )




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



      """simple docstring"""

      UpperCAmelCase_						:    Dict    					=  Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO""" ) ) / """000000039769.png""" )
      UpperCAmelCase_						:    List[str]    					=  self.tool(a_ )
      self.assertEqual(a_     ,   """two cats sleeping on a couch""" )




 def   a      ( self       : Optional[int] )->					Dict:



      """simple docstring"""

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




 def   a      ( self       : Dict )->					int:



      """simple docstring"""

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






 def   a      ( self       : Dict )->					Tuple:



      """simple docstring"""

      UpperCAmelCase_						:    Optional[Any]    					=  Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO""" ) ) / """000000039769.png""" )
      UpperCAmelCase_						:    List[str]    					=  self.remote_tool(image=a_ )
      self.assertEqual(a_     ,   """two cats sleeping on a couch""" )



"""simple docstring"""







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowercase_						    =					{"configuration_visual_bert": ["VISUAL_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "VisualBertConfig"]}

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       lowercase_						    =					[
           "VISUAL_BERT_PRETRAINED_MODEL_ARCHIVE_LIST",
           "VisualBertForMultipleChoice",
           "VisualBertForPreTraining",
           "VisualBertForQuestionAnswering",
           "VisualBertForRegionToPhraseAlignment",
           "VisualBertForVisualReasoning",
           "VisualBertLayer",
           "VisualBertModel",
           "VisualBertPreTrainedModel",
       ]


if TYPE_CHECKING:
       from .configuration_visual_bert import VISUAL_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, VisualBertConfig

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_visual_bert import (
                  VISUAL_BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
                  VisualBertForMultipleChoice,
                  VisualBertForPreTraining,
                  VisualBertForQuestionAnswering,
                  VisualBertForRegionToPhraseAlignment,
                  VisualBertForVisualReasoning,
                  VisualBertLayer,
                  VisualBertModel,
                  VisualBertPreTrainedModel,
              )


else:
       import sys

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

