




# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

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


_lowerCamelCase			 =						{
    'agents': ['Agent', 'AzureOpenAiAgent', 'HfAgent', 'LocalAgent', 'OpenAiAgent'],
    'base': ['PipelineTool', 'RemoteTool', 'Tool', 'launch_gradio_demo', 'load_tool'],
}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 _lowerCamelCase			 =						['DocumentQuestionAnsweringTool']
 _lowerCamelCase			 =						['ImageCaptioningTool']
 _lowerCamelCase			 =						['ImageQuestionAnsweringTool']
 _lowerCamelCase			 =						['ImageSegmentationTool']
 _lowerCamelCase			 =						['SpeechToTextTool']
 _lowerCamelCase			 =						['TextClassificationTool']
 _lowerCamelCase			 =						['TextQuestionAnsweringTool']
 _lowerCamelCase			 =						['TextSummarizationTool']
 _lowerCamelCase			 =						['TextToSpeechTool']
 _lowerCamelCase			 =						['TranslationTool']

if TYPE_CHECKING:
 from .agents import Agent, AzureOpenAiAgent, HfAgent, LocalAgent, OpenAiAgent
 from .base import PipelineTool, RemoteTool, Tool, launch_gradio_demo, load_tool

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .document_question_answering import DocumentQuestionAnsweringTool
  from .image_captioning import ImageCaptioningTool
  from .image_question_answering import ImageQuestionAnsweringTool
  from .image_segmentation import ImageSegmentationTool
  from .speech_to_text import SpeechToTextTool
  from .text_classification import TextClassificationTool
  from .text_question_answering import TextQuestionAnsweringTool
  from .text_summarization import TextSummarizationTool
  from .text_to_speech import TextToSpeechTool
  from .translation import TranslationTool
else:
 import sys

 _lowerCamelCase			 =						_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)











from typing import Optional, Union

from ...file_utils import TensorType
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, TruncationStrategy



class 			a     (   _A			):

     '''simple docstring'''





     lowerCAmelCase				:       Any   		=  'MarkupLMFeatureExtractor'
     lowerCAmelCase				:       Optional[Any]   		=  ('MarkupLMTokenizer', 'MarkupLMTokenizerFast')
     lowerCAmelCase				:       List[Any]   		=  True
     def __call__(	self   :			Dict					,    __snake_case   :			Tuple=None					,    __snake_case   :			List[Any]=None					,    __snake_case   :			Tuple=None					,    __snake_case   :			Tuple=None					,    __snake_case   :			Any=None					,    __snake_case   :			bool = True					,    __snake_case   :			Union[bool, str, PaddingStrategy] = False					,    __snake_case   :			Union[bool, str, TruncationStrategy] = None					,    __snake_case   :			Optional[int] = None					,    __snake_case   :			int = 0					,    __snake_case   :			Optional[int] = None					,    __snake_case   :			Optional[bool] = None					,    __snake_case   :			Optional[bool] = None					,    __snake_case   :			bool = False					,    __snake_case   :			bool = False					,    __snake_case   :			bool = False					,    __snake_case   :			bool = False					,    __snake_case   :			bool = True					,    __snake_case   :			Optional[Union[str, TensorType]] = None					,    **__snake_case   :			Any					,    ):
         # first, create nodes and xpaths
         if self.parse_html:
             if html_strings is None:
                 raise ValueError('''Make sure to pass HTML strings in case `parse_html` is set to `True`'''				)

             if nodes is not None or xpaths is not None or node_labels is not None:
                 raise ValueError(
                     '''Please don\'t pass nodes, xpaths nor node labels in case `parse_html` is set to `True`'''				)

             UpperCAmelCase_							 =     self.feature_extractor(__snake_case				)
             UpperCAmelCase_							 =     features['''nodes''']
             UpperCAmelCase_							 =     features['''xpaths''']
         else:
             if html_strings is not None:
                 raise ValueError('''You have passed HTML strings but `parse_html` is set to `False`.'''				)
             if nodes is None or xpaths is None:
                 raise ValueError('''Make sure to pass nodes and xpaths in case `parse_html` is set to `False`'''				)

        # # second, apply the tokenizer
         if questions is not None and self.parse_html:
             if isinstance(__snake_case					,    __snake_case				):
                 UpperCAmelCase_							 =     [questions]  # add batch dimension (as the feature extractor always adds a batch dimension)

         UpperCAmelCase_							 =     self.tokenizer(
             text=questions if questions is not None else nodes					,    text_pair=nodes if questions is not None else None					,    xpaths=__snake_case					,    node_labels=__snake_case					,    add_special_tokens=__snake_case					,    padding=__snake_case					,    truncation=__snake_case					,    max_length=__snake_case					,    stride=__snake_case					,    pad_to_multiple_of=__snake_case					,    return_token_type_ids=__snake_case					,    return_attention_mask=__snake_case					,    return_overflowing_tokens=__snake_case					,    return_special_tokens_mask=__snake_case					,    return_offsets_mapping=__snake_case					,    return_length=__snake_case					,    verbose=__snake_case					,    return_tensors=__snake_case					,    **__snake_case					,    )

         return encoded_inputs
     def   lowerCamelCase_   (	self   :			List[Any]					,    *__snake_case   :			Dict					,    **__snake_case   :			Optional[int]				):
         return self.tokenizer.batch_decode(*__snake_case					,    **__snake_case				)
     def   lowerCamelCase_   (	self   :			Optional[Any]					,    *__snake_case   :			Any					,    **__snake_case   :			Dict				):
         return self.tokenizer.decode(*__snake_case					,    **__snake_case				)




     @property
     def   lowerCamelCase_   (	self   :			Dict				):
         UpperCAmelCase_							 =     self.tokenizer.model_input_names
         return tokenizer_input_names





