'''simple docstring'''




from collections.abc import Sequence
from queue import Queue





class 					__magic_name__		:







			def __init__(			self       :						Union[str, Any]       ,    lowercase_       :						Any       ,    lowercase_       :						List[Any]       ,    lowercase_       :						Tuple       ,    lowercase_       :						Dict=None       ,    lowercase_       :						Optional[Any]=None					):
										lowercase_      :    Union[str, Any]       		= start
										lowercase_      :    List[str]       		= end
										lowercase_      :    Tuple       		= val
										lowercase_      :    Optional[Any]       		= (start + end) // 2
										lowercase_      :    Any       		= left
										lowercase_      :    str       		= right







			def __repr__(			self       :						Optional[int]					):
										return f'''SegmentTreeNode(start={self.start}, end={self.end}, val={self.val})'''





class 					__magic_name__		:







			def __init__(			self       :						Any       ,    lowercase_       :						Sequence       ,    lowercase_       :						Optional[Any]					):
										lowercase_      :    str       		= collection
										lowercase_      :    List[Any]       		= function
										if self.collection:
																	lowercase_      :    int       		= self._build_tree(0       ,    len(lowercase_					) - 1					)







			def 			SCREAMING_SNAKE_CASE_  (			self       :						Any       ,    lowercase_       :						int       ,    lowercase_       :						Optional[int]					):
										self._update_tree(self.root       ,    lowercase_       ,    lowercase_					)







			def 			SCREAMING_SNAKE_CASE_  (			self       :						List[Any]       ,    lowercase_       :						List[str]       ,    lowercase_       :						Optional[Any]					):
										return self._query_range(self.root       ,    lowercase_       ,    lowercase_					)







			def 			SCREAMING_SNAKE_CASE_  (			self       :						Optional[Any]       ,    lowercase_       :						Dict       ,    lowercase_       :						Tuple					):
										if start == end:
																	return SegmentTreeNode(lowercase_       ,    lowercase_       ,    self.collection[start]					)
										lowercase_      :    Union[str, Any]       		= (start + end) // 2
										lowercase_      :    int       		= self._build_tree(lowercase_       ,    lowercase_					)
										lowercase_      :    int       		= self._build_tree(mid + 1       ,    lowercase_					)
										return SegmentTreeNode(lowercase_       ,    lowercase_       ,    self.fn(left.val       ,    right.val					)       ,    lowercase_       ,    lowercase_					)







			def 			SCREAMING_SNAKE_CASE_  (			self       :						str       ,    lowercase_       :						Dict       ,    lowercase_       :						List[Any]       ,    lowercase_       :						Optional[Any]					):
										if node.start == i and node.end == i:
																	lowercase_      :    List[Any]       		= val
																	return
										if i <= node.mid:
																	self._update_tree(node.left       ,    lowercase_       ,    lowercase_					)
										else:
																	self._update_tree(node.right       ,    lowercase_       ,    lowercase_					)
										lowercase_      :    Optional[int]       		= self.fn(node.left.val       ,    node.right.val					)







			def 			SCREAMING_SNAKE_CASE_  (			self       :						str       ,    lowercase_       :						Any       ,    lowercase_       :						Optional[Any]       ,    lowercase_       :						Dict					):
										if node.start == i and node.end == j:
																	return node.val

										if i <= node.mid:
																	if j <= node.mid:
																								# range in left child tree
																								return self._query_range(node.left       ,    lowercase_       ,    lowercase_					)
																	else:
																								# range in left child tree and right child tree
																								return self.fn(
																								    self._query_range(node.left       ,    lowercase_       ,    node.mid					)       ,    self._query_range(node.right       ,    node.mid + 1       ,    lowercase_					)       ,    )
										else:
																	# range in right child tree
																	return self._query_range(node.right       ,    lowercase_       ,    lowercase_					)







			def 			SCREAMING_SNAKE_CASE_  (			self       :						Any					):
										if self.root is not None:
																	lowercase_      :    Tuple       		= Queue()
																	queue.put(self.root					)
																	while not queue.empty():
																								lowercase_      :    int       		= queue.get()
																								yield node

																								if node.left is not None:
																															queue.put(node.left					)

																								if node.right is not None:
																															queue.put(node.right					)


if __name__ == "__main__":
						import operator

						for fn in [operator.add, max, min]:
												print("*" * 50)
												_lowercase		:				Optional[int]	       =		SegmentTree([2, 1, 5, 3, 4], fn)
												for node in arr.traverse():
																		print(node)
												print()

												arr.update(1, 5)
												for node in arr.traverse():
																		print(node)
												print()

												print(arr.query_range(3, 4))  # 7
												print(arr.query_range(2, 2))  # 5
												print(arr.query_range(1, 3))  # 13
												print()






'''simple docstring'''




from ...configuration_utils import PretrainedConfig
from ...utils import logging


_lowercase		:				Optional[Any]	       =		logging.get_logger(__name__)

_lowercase		:				Union[str, Any]	       =		{
    "facebook/s2t-small-librispeech-asr": (
        "https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config.json"
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech_to_text
}





class 					__magic_name__		(					_UpperCAmelCase):
			UpperCamelCase__       = '''speech_to_text'''
			UpperCamelCase__       = ['''past_key_values''']
			UpperCamelCase__       = {'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}







			def __init__(			self       :						str       ,    lowercase_       :						Optional[int]=10000       ,    lowercase_       :						int=12       ,    lowercase_       :						Any=2048       ,    lowercase_       :						Any=4       ,    lowercase_       :						Dict=6       ,    lowercase_       :						Any=2048       ,    lowercase_       :						List[str]=4       ,    lowercase_       :						str=0.0       ,    lowercase_       :						str=0.0       ,    lowercase_       :						Union[str, Any]=True       ,    lowercase_       :						List[Any]=True       ,    lowercase_       :						int="relu"       ,    lowercase_       :						str=256       ,    lowercase_       :						int=0.1       ,    lowercase_       :						int=0.0       ,    lowercase_       :						str=0.0       ,    lowercase_       :						Optional[int]=0.02       ,    lowercase_       :						str=2       ,    lowercase_       :						Union[str, Any]=True       ,    lowercase_       :						Any=1       ,    lowercase_       :						Dict=0       ,    lowercase_       :						List[str]=2       ,    lowercase_       :						List[Any]=6000       ,    lowercase_       :						Tuple=1024       ,    lowercase_       :						str=2       ,    lowercase_       :						Any=(5, 5)       ,    lowercase_       :						Union[str, Any]=1024       ,    lowercase_       :						Dict=80       ,    lowercase_       :						List[Any]=1       ,    **lowercase_       :						int       ,    ):
										lowercase_      :    List[Any]       		= vocab_size
										lowercase_      :    str       		= d_model
										lowercase_      :    List[Any]       		= encoder_ffn_dim
										lowercase_      :    str       		= encoder_layers
										lowercase_      :    Dict       		= encoder_attention_heads
										lowercase_      :    str       		= decoder_ffn_dim
										lowercase_      :    int       		= decoder_layers
										lowercase_      :    Any       		= decoder_attention_heads
										lowercase_      :    Any       		= dropout
										lowercase_      :    Dict       		= attention_dropout
										lowercase_      :    Optional[int]       		= activation_dropout
										lowercase_      :    Any       		= activation_function
										lowercase_      :    Union[str, Any]       		= init_std
										lowercase_      :    str       		= encoder_layerdrop
										lowercase_      :    Optional[int]       		= decoder_layerdrop
										lowercase_      :    Dict       		= use_cache
										lowercase_      :    Union[str, Any]       		= encoder_layers
										lowercase_      :    Tuple       		= scale_embedding  # scale factor will be sqrt(d_model) if True
										lowercase_      :    Dict       		= max_source_positions
										lowercase_      :    Optional[int]       		= max_target_positions
										lowercase_      :    Tuple       		= num_conv_layers
										lowercase_      :    Tuple       		= list(lowercase_					)
										lowercase_      :    Union[str, Any]       		= conv_channels
										lowercase_      :    str       		= input_feat_per_channel
										lowercase_      :    str       		= input_channels

										if len(self.conv_kernel_sizes					) != self.num_conv_layers:
																	raise ValueError(
																	    """Configuration for convolutional module is incorrect. """
																	    """It is required that `len(config.conv_kernel_sizes)` == `config.num_conv_layers` """
																	    f'''but is `len(config.conv_kernel_sizes) = {len(self.conv_kernel_sizes					)}`, '''
																	    f'''`config.num_conv_layers = {self.num_conv_layers}`.'''					)

										super().__init__(
										    pad_token_id=lowercase_       ,    bos_token_id=lowercase_       ,    eos_token_id=lowercase_       ,    is_encoder_decoder=lowercase_       ,    decoder_start_token_id=lowercase_       ,    **lowercase_       ,    )





