
"""simple docstring"""

from typing import Optional, Union

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






class 			_lowercase  (							__UpperCAmelCase						):
	lowercase_								=      """MarkupLMFeatureExtractor"""
	lowercase_								=      ("""MarkupLMTokenizer""", """MarkupLMTokenizerFast""")
	lowercase_								=      True




	def __call__(					self						,					UpperCAmelCase_=None						,					UpperCAmelCase_=None						,					UpperCAmelCase_=None						,					UpperCAmelCase_=None						,					UpperCAmelCase_=None						,					UpperCAmelCase_ = True						,					UpperCAmelCase_ = False						,					UpperCAmelCase_ = None						,					UpperCAmelCase_ = None						,					UpperCAmelCase_ = 0						,					UpperCAmelCase_ = None						,					UpperCAmelCase_ = None						,					UpperCAmelCase_ = None						,					UpperCAmelCase_ = False						,					UpperCAmelCase_ = False						,					UpperCAmelCase_ = False						,					UpperCAmelCase_ = False						,					UpperCAmelCase_ = True						,					UpperCAmelCase_ = None						,					**UpperCAmelCase_						,					)						->				BatchEncoding:







			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`'   )

					lowerCamelCase	:     Union[str, Any]            =       self.feature_extractor(UpperCAmelCase__   )
					lowerCamelCase	:     List[str]            =       features["""nodes"""]
					lowerCamelCase	:     Tuple            =       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(UpperCAmelCase__						,					UpperCAmelCase__   ):
							lowerCamelCase	:     Any            =       [questions]  # add batch dimension (as the feature extractor always adds a batch dimension)

			lowerCamelCase	:     Union[str, Any]            =       self.tokenizer(
			    text=questions if questions is not None else nodes						,					text_pair=nodes if questions is not None else None						,					xpaths=UpperCAmelCase__						,					node_labels=UpperCAmelCase__						,					add_special_tokens=UpperCAmelCase__						,					padding=UpperCAmelCase__						,					truncation=UpperCAmelCase__						,					max_length=UpperCAmelCase__						,					stride=UpperCAmelCase__						,					pad_to_multiple_of=UpperCAmelCase__						,					return_token_type_ids=UpperCAmelCase__						,					return_attention_mask=UpperCAmelCase__						,					return_overflowing_tokens=UpperCAmelCase__						,					return_special_tokens_mask=UpperCAmelCase__						,					return_offsets_mapping=UpperCAmelCase__						,					return_length=UpperCAmelCase__						,					verbose=UpperCAmelCase__						,					return_tensors=UpperCAmelCase__						,					**UpperCAmelCase__						,					)

			return encoded_inputs




	def      _UpperCamelCase       (					self						,					*UpperCAmelCase_						,					**UpperCAmelCase_   )						->				Optional[Any]:
			return self.tokenizer.batch_decode(*UpperCAmelCase__						,					**UpperCAmelCase__   )




	def      _UpperCamelCase       (					self						,					*UpperCAmelCase_						,					**UpperCAmelCase_   )						->				List[Any]:
			return self.tokenizer.decode(*UpperCAmelCase__						,					**UpperCAmelCase__   )




	@property
	def      _UpperCamelCase       (					self   )						->				Optional[Any]:
			lowerCamelCase	:     Tuple            =       self.tokenizer.model_input_names
			return tokenizer_input_names









from typing import TYPE_CHECKING

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


UpperCAmelCase__			:  Tuple					     =     {
    """configuration_speech_to_text_2""": ["""SPEECH_TO_TEXT_2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Speech2Text2Config"""],
    """processing_speech_to_text_2""": ["""Speech2Text2Processor"""],
    """tokenization_speech_to_text_2""": ["""Speech2Text2Tokenizer"""],
}


try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase__			:  Tuple					     =     [
      """SPEECH_TO_TEXT_2_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """Speech2Text2ForCausalLM""",
      """Speech2Text2PreTrainedModel""",
  ]


if TYPE_CHECKING:
  from .configuration_speech_to_text_a import SPEECH_TO_TEXT_2_PRETRAINED_CONFIG_ARCHIVE_MAP, SpeechaTextaConfig
  from .processing_speech_to_text_a import SpeechaTextaProcessor
  from .tokenization_speech_to_text_a import SpeechaTextaTokenizer

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_speech_to_text_a import (
        SPEECH_TO_TEXT_2_PRETRAINED_MODEL_ARCHIVE_LIST,
        SpeechaTextaForCausalLM,
        SpeechaTextaPreTrainedModel,
    )

else:
  import sys

  UpperCAmelCase__			:  Optional[int]					     =     _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)




