



'''simple docstring'''



from __future__ import annotations

from collections.abc import Callable
from typing import Any, Generic, TypeVar

__UpperCamelCase      :       List[str]      			=      TypeVar("""T""")
class 							__SCREAMING_SNAKE_CASE       (							Generic[T]     ):




      def __init__(  self ,   lowerCamelCase ,   lowerCamelCase      )							->None:



         '''simple docstring'''
         __a				     =    None

         __a				     =    len(lowerCamelCase      )
         __a				     =    [any_type for _ in range(self.N      )] + arr
         __a				     =    fnc
         self.build()




      def  __UpperCamelCase							(  self      )							->None:



         '''simple docstring'''
         for p in range(self.N - 1 ,   0 ,   -1      ):
            __a				     =    self.fn(self.st[p * 2] ,   self.st[p * 2 + 1]      )




      def  __UpperCamelCase							(  self ,   lowerCamelCase ,   lowerCamelCase      )							->None:



         '''simple docstring'''
         p += self.N
         __a				     =    v
         while p > 1:
            __a				     =    p // 2
            __a				     =    self.fn(self.st[p * 2] ,   self.st[p * 2 + 1]      )






      def  __UpperCamelCase							(  self ,   lowerCamelCase ,   lowerCamelCase      )							->T | None:  # noqa: E741



         '''simple docstring'''
         __a     ,			__a				     =    l + self.N, r + self.N

         __a				     =    None
         while l <= r:
            if l % 2 == 1:
               __a				     =    self.st[l] if res is None else self.fn(lowerCamelCase ,   self.st[l]      )
            if r % 2 == 0:
               __a				     =    self.st[r] if res is None else self.fn(lowerCamelCase ,   self.st[r]      )
            __a     ,			__a				     =    (l + 1) // 2, (r - 1) // 2
         return res


if __name__ == "__main__":
 from functools import reduce

 __UpperCamelCase      :       Optional[int]      			=      [1, 10, -2, 9, -3, 8, 4, -7, 5, 6, 11, -12]

 __UpperCamelCase      :       Any      			=      {
     0: 7,
     1: 2,
     2: 6,
     3: -14,
     4: 5,
     5: 4,
     6: 7,
     7: -10,
     8: 9,
     9: 10,
     10: 12,
     11: 1,
 }

 __UpperCamelCase      :       Tuple      			=      SegmentTree(test_array, min)
 __UpperCamelCase      :       List[Any]      			=      SegmentTree(test_array, max)
 __UpperCamelCase      :       Optional[Any]      			=      SegmentTree(test_array, lambda a, b: a + b)



 def    __UpperCAmelCase	(				)  ->			None:

    """simple docstring"""
    for i in range(len(SCREAMING_SNAKE_CASE__    )    ):
       for j in range(SCREAMING_SNAKE_CASE__,					len(SCREAMING_SNAKE_CASE__    )    ):
          __a				     =    reduce(SCREAMING_SNAKE_CASE__,					test_array[i : j + 1]    )
          __a				     =    reduce(SCREAMING_SNAKE_CASE__,					test_array[i : j + 1]    )
          __a				     =    reduce(lambda SCREAMING_SNAKE_CASE__,					SCREAMING_SNAKE_CASE__    : a + b,					test_array[i : j + 1]    )
          assert min_range == min_segment_tree.query(SCREAMING_SNAKE_CASE__,					SCREAMING_SNAKE_CASE__    )
          assert max_range == max_segment_tree.query(SCREAMING_SNAKE_CASE__,					SCREAMING_SNAKE_CASE__    )
          assert sum_range == sum_segment_tree.query(SCREAMING_SNAKE_CASE__,					SCREAMING_SNAKE_CASE__    )

 test_all_segments()

 for index, value in test_updates.items():
  __UpperCamelCase      :       Any      			=      value
  min_segment_tree.update(index, value)
  max_segment_tree.update(index, value)
  sum_segment_tree.update(index, value)
  test_all_segments()







'''simple docstring'''



from typing import TYPE_CHECKING

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


__UpperCamelCase      :       Optional[int]      			=      {
    """configuration_speech_to_text""": ["""SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Speech2TextConfig"""],
    """processing_speech_to_text""": ["""Speech2TextProcessor"""],
}

try:
 if not is_sentencepiece_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __UpperCamelCase      :       Union[str, Any]      			=      ["""Speech2TextTokenizer"""]

try:
 if not is_speech_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __UpperCamelCase      :       Optional[Any]      			=      ["""Speech2TextFeatureExtractor"""]

try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __UpperCamelCase      :       List[Any]      			=      [
     """TF_SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST""",
     """TFSpeech2TextForConditionalGeneration""",
     """TFSpeech2TextModel""",
     """TFSpeech2TextPreTrainedModel""",
 ]

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __UpperCamelCase      :       Tuple      			=      [
     """SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST""",
     """Speech2TextForConditionalGeneration""",
     """Speech2TextModel""",
     """Speech2TextPreTrainedModel""",
 ]


if TYPE_CHECKING:
 from .configuration_speech_to_text import SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP, SpeechaTextConfig
 from .processing_speech_to_text import SpeechaTextProcessor

 try:
  if not is_sentencepiece_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_speech_to_text import SpeechaTextTokenizer

 try:
  if not is_speech_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .feature_extraction_speech_to_text import SpeechaTextFeatureExtractor

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_speech_to_text import (
      TF_SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFSpeechaTextForConditionalGeneration,
      TFSpeechaTextModel,
      TFSpeechaTextPreTrainedModel,
  )

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_speech_to_text import (
      SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
      SpeechaTextForConditionalGeneration,
      SpeechaTextModel,
      SpeechaTextPreTrainedModel,
  )

else:
 import sys

 __UpperCamelCase      :       List[str]      			=      _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)