






import enum
import inspect
import warnings
from functools import wraps
from typing import Callable, Optional

from .logging import get_logger


A__     :      Tuple             =			set()
A__     :      List[str]             =			get_logger(__name__)






def   a      (						lowerCamelCase_ = None    ):






				'''simple docstring'''

				def decorator(lowerCamelCase_    ):
								global _emitted_deprecation_warnings

								if inspect.isclass(lowerCamelCase_    ):
												lowercase__       			=      deprecated_class_or_function.__init__
												lowercase__       			=      deprecated_class_or_function.__name__
								else:
												lowercase__       			=      deprecated_class_or_function
												lowercase__       			=      deprecated_function.__name__
												# Support deprecating __init__ class method: class name instead
												lowercase__       			=      name if name != '''__init__''' else deprecated_function.__qualname__.split('''.'''    )[-2]

								lowercase__       			=      (
								    F"""{name} is deprecated and will be removed in the next major version of datasets.""" + F""" {help_message}"""
								    if help_message
								    else ''''''
								)

								@wraps(lowerCamelCase_    )
								def wrapper(*lowerCamelCase_		,       **lowerCamelCase_    ):
												lowercase__       			=      hash(lowerCamelCase_    )
												if func_hash not in _emitted_deprecation_warnings:
																warnings.warn(lowerCamelCase_		,       category=lowerCamelCase_		,       stacklevel=2    )
																_emitted_deprecation_warnings.add(lowerCamelCase_    )
												return deprecated_function(*lowerCamelCase_		,       **lowerCamelCase_    )

								lowercase__       			=      '''deprecated'''

								if inspect.isclass(lowerCamelCase_    ):
												lowercase__       			=      wrapper
												return deprecated_class_or_function
								else:
												return wrapper

				return decorator
class 				_UpperCAmelCase (	enum.EnumMeta     ):

				"""simple docstring"""




				def __getattribute__(					cls						:   List[Any],  lowerCamelCase						:   Optional[int]  ):

								'''simple docstring'''
								lowercase__       			=      super().__getattribute__(lowerCamelCase  )
								if isinstance(lowerCamelCase,  enum.Enum  ) and obj._on_access:
												obj._on_access()
								return obj




				def __getitem__(					cls						:   List[str],  lowerCamelCase						:   Optional[int]  ):

								'''simple docstring'''
								lowercase__       			=      super().__getitem__(lowerCamelCase  )
								if member._on_access:
												member._on_access()
								return member




				def __call__(					cls						:   int,  lowerCamelCase						:   List[str],  lowerCamelCase						:   Any=None,  *, lowerCamelCase						:   Any=None,  lowerCamelCase						:   List[Any]=None,  lowerCamelCase						:   Union[str, Any]=None,  lowerCamelCase						:   Optional[int]=1  ):

								'''simple docstring'''
								lowercase__       			=      super().__call__(lowerCamelCase,  lowerCamelCase,  module=lowerCamelCase,  qualname=lowerCamelCase,  type=lowerCamelCase,  start=lowerCamelCase  )
								if isinstance(lowerCamelCase,  enum.Enum  ) and obj._on_access:
												obj._on_access()
								return obj



class 				_UpperCAmelCase (	enum.Enum		,metaclass=A__     ):

				"""simple docstring"""




				def __new__(					cls						:   Dict,  lowerCamelCase						:   Optional[Any]  ):

								'''simple docstring'''
								lowercase__       			=      object.__new__(cls  )
								lowercase__       			=      value
								lowercase__       			=      member.deprecate
								return member




				@property
				def     lowercase__       (					self						:   Union[str, Any]  ):

								'''simple docstring'''
								return ""




				def     lowercase__       (					self						:   Union[str, Any]  ):

								'''simple docstring'''
								lowercase__       			=      F""" {self.help_message}""" if self.help_message else ''''''
								warnings.warn(
								    F"""'{self.__objclass__.__name__}' is deprecated and will be removed in the next major version of datasets."""
								    + help_message,  lowerCamelCase,  stacklevel=3,  )












import unittest

from datasets import load_dataset

from transformers import load_tool

from .test_tools_common import ToolTesterMixin
class 				_UpperCAmelCase (	unittest.TestCase		,A__     ):

				"""simple docstring"""




				def     lowercase__       (					self						:   str  ):

								'''simple docstring'''
								lowercase__       			=      load_tool('''document-question-answering'''  )
								self.tool.setup()
								lowercase__       			=      load_tool('''document-question-answering''',  remote=lowerCamelCase  )




				def     lowercase__       (					self						:   List[Any]  ):

								'''simple docstring'''
								lowercase__       			=      load_dataset('''hf-internal-testing/example-documents''',  split='''test'''  )
								lowercase__       			=      dataset[0]['''image''']

								lowercase__       			=      self.tool(lowerCamelCase,  '''When is the coffee break?'''  )
								self.assertEqual(lowerCamelCase,  '''11-14 to 11:39 a.m.'''  )




				def     lowercase__       (					self						:   Optional[Any]  ):

								'''simple docstring'''
								lowercase__       			=      load_dataset('''hf-internal-testing/example-documents''',  split='''test'''  )
								lowercase__       			=      dataset[0]['''image''']

								lowercase__       			=      self.remote_tool(lowerCamelCase,  '''When is the coffee break?'''  )
								self.assertEqual(lowerCamelCase,  '''11-14 to 11:39 a.m.'''  )




				def     lowercase__       (					self						:   Any  ):

								'''simple docstring'''
								lowercase__       			=      load_dataset('''hf-internal-testing/example-documents''',  split='''test'''  )
								lowercase__       			=      dataset[0]['''image''']

								self.tool(document=lowerCamelCase,  question='''When is the coffee break?'''  )




				def     lowercase__       (					self						:   Tuple  ):

								'''simple docstring'''
								lowercase__       			=      load_dataset('''hf-internal-testing/example-documents''',  split='''test'''  )
								lowercase__       			=      dataset[0]['''image''']

								lowercase__       			=      self.remote_tool(document=lowerCamelCase,  question='''When is the coffee break?'''  )
								self.assertEqual(lowerCamelCase,  '''11-14 to 11:39 a.m.'''  )




