



'''simple docstring'''






from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Mapping, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast
from ...utils import logging


if TYPE_CHECKING:
						from ...feature_extraction_utils import FeatureExtractionMixin
						from ...tokenization_utils_base import PreTrainedTokenizerBase
						from ...utils import TensorType

UpperCamelCase__:   Any								=			logging.get_logger(__name__)

UpperCamelCase__:   Union[str, Any]								=			{
    "openai/whisper-base": "https://huggingface.co/openai/whisper-base/resolve/main/config.json",
}

# fmt: off
UpperCamelCase__:   Optional[Any]								=			[
    1, 2, 7, 8, 9, 10, 14, 25,
    26, 27, 28, 29, 31, 58, 59, 60, 61, 62,
    63, 90, 91, 92, 93, 357, 366, 438, 532, 685,
    705, 796, 930, 1058, 1220, 1267, 1279, 1303, 1343, 1377,
    1391, 1635, 1782, 1875, 2162, 2361, 2488, 3467, 4008, 4211,
    4600, 4808, 5299, 5855, 6329, 7203, 9609, 9959, 10563, 10786,
    11420, 11709, 11907, 13163, 13697, 13700, 14808, 15306, 16410, 16791,
    17992, 19203, 19510, 20724, 22305, 22935, 27007, 30109, 30420, 33409,
    34949, 40283, 40493, 40549, 47282, 49146, 50257, 50359, 50360, 50361
]
UpperCamelCase__:   List[str]								=			[
    1, 2, 7, 8, 9, 10, 14, 25,
    26, 27, 28, 29, 31, 58, 59, 60, 61, 62,
    63, 90, 91, 92, 93, 359, 503, 522, 542, 873,
    893, 902, 918, 922, 931, 1350, 1853, 1982, 2460, 2627,
    3246, 3253, 3268, 3536, 3846, 3961, 4183, 4667, 6585, 6647,
    7273, 9061, 9383, 10428, 10929, 11938, 12033, 12331, 12562, 13793,
    14157, 14635, 15265, 15618, 16553, 16604, 18362, 18956, 20075, 21675,
    22520, 26130, 26161, 26435, 28279, 29464, 31650, 32302, 32470, 36865,
    42863, 47425, 49870, 50254, 50258, 50360, 50361, 50362
]

class 				SCREAMING_SNAKE_CASE(							A__			):







	"""simple docstring"""






	lowerCamelCase__			 =       """whisper"""
	lowerCamelCase__			 =       ["""past_key_values"""]
	lowerCamelCase__			 =       {"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}







	def __init__(						self			:     Dict		,			__snake_case			:     Tuple=51865		,			__snake_case			:     Union[str, Any]=80		,			__snake_case			:     str=6		,			__snake_case			:     int=4		,			__snake_case			:     Optional[Any]=6		,			__snake_case			:     Tuple=4		,			__snake_case			:     Optional[Any]=1536		,			__snake_case			:     Tuple=1536		,			__snake_case			:     Union[str, Any]=0.0		,			__snake_case			:     List[str]=0.0		,			__snake_case			:     Optional[int]=50257		,			__snake_case			:     Dict=True		,			__snake_case			:     int=True		,			__snake_case			:     Optional[int]="gelu"		,			__snake_case			:     Tuple=256		,			__snake_case			:     Any=0.0		,			__snake_case			:     List[Any]=0.0		,			__snake_case			:     str=0.0		,			__snake_case			:     str=0.02		,			__snake_case			:     List[str]=False		,			__snake_case			:     Any=1500		,			__snake_case			:     List[Any]=448		,			__snake_case			:     Any=50256		,			__snake_case			:     List[Any]=50256		,			__snake_case			:     Tuple=50256		,			__snake_case			:     Optional[Any]=None		,			__snake_case			:     str=[220, 50256]		,			__snake_case			:     Tuple=False		,			__snake_case			:     Dict=256		,			__snake_case			:     Tuple=False		,			__snake_case			:     Tuple=0.05		,			__snake_case			:     int=10		,			__snake_case			:     str=2		,			__snake_case			:     Optional[Any]=0.0		,			__snake_case			:     str=10		,			__snake_case			:     Optional[int]=0		,			__snake_case			:     Optional[int]=7		,			**__snake_case			:     Optional[int]		,			)			->		List[str]:
								UpperCAmelCase :       List[str] 							=		vocab_size
								UpperCAmelCase :       int 							=		num_mel_bins
								UpperCAmelCase :       Optional[int] 							=		d_model
								UpperCAmelCase :       str 							=		encoder_layers
								UpperCAmelCase :       Tuple 							=		encoder_attention_heads
								UpperCAmelCase :       Optional[Any] 							=		decoder_layers
								UpperCAmelCase :       List[str] 							=		decoder_attention_heads
								UpperCAmelCase :       int 							=		decoder_ffn_dim
								UpperCAmelCase :       List[str] 							=		encoder_ffn_dim
								UpperCAmelCase :       List[str] 							=		dropout
								UpperCAmelCase :       List[str] 							=		attention_dropout
								UpperCAmelCase :       Optional[int] 							=		activation_dropout
								UpperCAmelCase :       Optional[int] 							=		activation_function
								UpperCAmelCase :       str 							=		init_std
								UpperCAmelCase :       Union[str, Any] 							=		encoder_layerdrop
								UpperCAmelCase :       Dict 							=		decoder_layerdrop
								UpperCAmelCase :       Union[str, Any] 							=		use_cache
								UpperCAmelCase :       List[Any] 							=		encoder_layers
								UpperCAmelCase :       List[Any] 							=		scale_embedding  # scale factor will be sqrt(d_model) if True
								UpperCAmelCase :       str 							=		max_source_positions
								UpperCAmelCase :       List[Any] 							=		max_target_positions

								# Audio Classification-specific parameters. Feel free to ignore for other classes.
								UpperCAmelCase :       str 							=		classifier_proj_size
								UpperCAmelCase :       Optional[int] 							=		use_weighted_layer_sum

								# fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
								UpperCAmelCase :       str 							=		apply_spec_augment
								UpperCAmelCase :       List[Any] 							=		mask_time_prob
								UpperCAmelCase :       str 							=		mask_time_length
								UpperCAmelCase :       Union[str, Any] 							=		mask_time_min_masks
								UpperCAmelCase :       str 							=		mask_feature_prob
								UpperCAmelCase :       List[Any] 							=		mask_feature_length
								UpperCAmelCase :       List[str] 							=		mask_feature_min_masks

								UpperCAmelCase :       Dict 							=		median_filter_width

								super().__init__(
								    pad_token_id=__snake_case		,			bos_token_id=__snake_case		,			eos_token_id=__snake_case		,			is_encoder_decoder=__snake_case		,			decoder_start_token_id=__snake_case		,			suppress_tokens=__snake_case		,			begin_suppress_tokens=__snake_case		,			**__snake_case		,			)

class 				SCREAMING_SNAKE_CASE(							A__			):







	"""simple docstring"""






	@property
	def      A	(						self			:     Optional[int]		)			->		Mapping[str, Mapping[int, str]]:
								UpperCAmelCase :       Dict 							=		OrderedDict(
								    [
								        ('''input_features''', {0: '''batch''', 1: '''feature_size''', 2: '''encoder_sequence'''}),
								    ]		)
								if self.use_past:
															UpperCAmelCase :       Any 							=		{0: '''batch'''}
								else:
															UpperCAmelCase :       List[Any] 							=		{0: '''batch''', 1: '''decoder_sequence'''}

								if self.use_past:
															self.fill_with_past_key_values_(__snake_case		,			direction='''inputs'''		)

								return common_inputs







	def      A	(						self			:     List[str]		,			__snake_case			:     Union["PreTrainedTokenizerBase", "FeatureExtractionMixin"]		,			__snake_case			:     int = -1		,			__snake_case			:     int = -1		,			__snake_case			:     bool = False		,			__snake_case			:     Optional["TensorType"] = None		,			__snake_case			:     int = 22050		,			__snake_case			:     float = 5.0		,			__snake_case			:     int = 220		,			)			->		Mapping[str, Any]:
								UpperCAmelCase :       int 							=		OrderedDict()
								UpperCAmelCase :       List[str] 							=		OnnxConfig.generate_dummy_inputs(
								    self		,			preprocessor=preprocessor.feature_extractor		,			batch_size=__snake_case		,			framework=__snake_case		,			sampling_rate=__snake_case		,			time_duration=__snake_case		,			frequency=__snake_case		,			)
								UpperCAmelCase :       int 							=		encoder_inputs['''input_features'''].shape[2]
								UpperCAmelCase :       Optional[int] 							=		encoder_sequence_length // 2 if self.use_past else seq_length

								UpperCAmelCase :       Optional[Any] 							=		super().generate_dummy_inputs(
								    preprocessor.tokenizer		,			__snake_case		,			__snake_case		,			__snake_case		,			__snake_case		)

								UpperCAmelCase :       Optional[int] 							=		encoder_inputs.pop('''input_features'''		)
								UpperCAmelCase :       int 							=		decoder_inputs.pop('''decoder_input_ids'''		)

								if "past_key_values" in decoder_inputs:
															UpperCAmelCase :       Union[str, Any] 							=		decoder_inputs.pop('''past_key_values'''		)

								return dummy_inputs







	@property
	def      A	(						self			:     List[Any]		)			->		float:
								return 1E-3







'''simple docstring'''




class  A				:





     def __init__(							self						,			SCREAMING_SNAKE_CASE						,			SCREAMING_SNAKE_CASE						,			SCREAMING_SNAKE_CASE	) ->				Tuple:






         """simple docstring"""






         A       :   Any					=						None
         A       :   Optional[Any]					=						None
         A       :   Tuple					=						graph

         self._normalize_graph(SCREAMING_SNAKE_CASE						,			SCREAMING_SNAKE_CASE	)
         A       :   Dict					=						len(SCREAMING_SNAKE_CASE	)
         A       :   Optional[Any]					=						None





     def 				__lowerCAmelCase							(							self						,			SCREAMING_SNAKE_CASE						,			SCREAMING_SNAKE_CASE	) ->				List[Any]:






         """simple docstring"""






         if sources is int:
             A       :   Dict					=						[sources]
         if sinks is int:
             A       :   str					=						[sinks]

         if len(SCREAMING_SNAKE_CASE	) == 0 or len(SCREAMING_SNAKE_CASE	) == 0:
             return

         A       :   Optional[int]					=						sources[0]
         A       :   Union[str, Any]					=						sinks[0]

         # make fake vertex if there are more
         # than one source or sink
         if len(SCREAMING_SNAKE_CASE	) > 1 or len(SCREAMING_SNAKE_CASE	) > 1:
             A       :   Optional[int]					=						0
             for i in sources:
                 max_input_flow += sum(self.graph[i]	)

             A       :   Dict					=						len(self.graph	) + 1
             for room in self.graph:
                 room.insert(0						,			0	)
             self.graph.insert(0						,			[0] * size	)
             for i in sources:
                 A       :   Dict					=						max_input_flow
             A       :   Tuple					=						0

             A       :   Tuple					=						len(self.graph	) + 1
             for room in self.graph:
                 room.append(0	)
             self.graph.append([0] * size	)
             for i in sinks:
                 A       :   Optional[Any]					=						max_input_flow
             A       :   Optional[Any]					=						size - 1





     def 				__lowerCAmelCase							(							self	) ->				Any:






         """simple docstring"""






         if self.maximum_flow_algorithm is None:
             raise Exception('''You need to set maximum flow algorithm before.'''	)
         if self.source_index is None or self.sink_index is None:
             return 0

         self.maximum_flow_algorithm.execute()
         return self.maximum_flow_algorithm.getMaximumFlow()





     def 				__lowerCAmelCase							(							self						,			SCREAMING_SNAKE_CASE	) ->				Union[str, Any]:






         """simple docstring"""






         A       :   List[Any]					=						algorithm(self	)





class  A				:





     def __init__(							self						,			SCREAMING_SNAKE_CASE	) ->				Union[str, Any]:






         """simple docstring"""






         A       :   Union[str, Any]					=						flow_network
         A       :   Optional[Any]					=						flow_network.verticesCount
         A       :   Tuple					=						flow_network.sourceIndex
         A       :   Dict					=						flow_network.sinkIndex
         # it's just a reference, so you shouldn't change
         # it in your algorithms, use deep copy before doing that
         A       :   str					=						flow_network.graph
         A       :   Optional[Any]					=						False





     def 				__lowerCAmelCase							(							self	) ->				Optional[int]:






         """simple docstring"""






         if not self.executed:
             self._algorithm()
             A       :   Optional[int]					=						True





     def 				__lowerCAmelCase							(							self	) ->				Any:






         """simple docstring"""






         pass





class  A				(							__snake_case						):





     def __init__(							self						,			SCREAMING_SNAKE_CASE	) ->				Dict:






         """simple docstring"""






         super().__init__(SCREAMING_SNAKE_CASE	)
         # use this to save your result
         A       :   List[str]					=						-1





     def 				__lowerCAmelCase							(							self	) ->				str:






         """simple docstring"""






         if not self.executed:
             raise Exception('''You should execute algorithm before using its result!'''	)

         return self.maximum_flow





class  A				(							__snake_case						):





     def __init__(							self						,			SCREAMING_SNAKE_CASE	) ->				List[Any]:






         """simple docstring"""






         super().__init__(SCREAMING_SNAKE_CASE	)

         A       :   Optional[Any]					=						[[0] * self.verticies_count for i in range(self.verticies_count	)]

         A       :   Union[str, Any]					=						[0] * self.verticies_count
         A       :   List[Any]					=						[0] * self.verticies_count





     def 				__lowerCAmelCase							(							self	) ->				Dict:






         """simple docstring"""






         A       :   Tuple					=						self.verticies_count

         # push some substance to graph
         for nextvertex_index, bandwidth in enumerate(self.graph[self.source_index]	):
             self.preflow[self.source_index][nextvertex_index] += bandwidth
             self.preflow[nextvertex_index][self.source_index] -= bandwidth
             self.excesses[nextvertex_index] += bandwidth

         # Relabel-to-front selection rule
         A       :   Optional[Any]					=						[
             i
             for i in range(self.verticies_count	)
             if i != self.source_index and i != self.sink_index
         ]

         # move through list
         A       :   Union[str, Any]					=						0
         while i < len(SCREAMING_SNAKE_CASE	):
             A       :   str					=						vertices_list[i]
             A       :   List[str]					=						self.heights[vertex_index]
             self.process_vertex(SCREAMING_SNAKE_CASE	)
             if self.heights[vertex_index] > previous_height:
                 # if it was relabeled, swap elements
                 # and start from 0 index
                 vertices_list.insert(0						,			vertices_list.pop(SCREAMING_SNAKE_CASE	)	)
                 A       :   int					=						0
             else:
                 i += 1

         A       :   Optional[Any]					=						sum(self.preflow[self.source_index]	)





     def 				__lowerCAmelCase							(							self						,			SCREAMING_SNAKE_CASE	) ->				Tuple:






         """simple docstring"""






         while self.excesses[vertex_index] > 0:
             for neighbour_index in range(self.verticies_count	):
                 # if it's neighbour and current vertex is higher
                 if (
                     self.graph[vertex_index][neighbour_index]
                     - self.preflow[vertex_index][neighbour_index]
                     > 0
                     and self.heights[vertex_index] > self.heights[neighbour_index]
                 ):
                     self.push(SCREAMING_SNAKE_CASE						,			SCREAMING_SNAKE_CASE	)

             self.relabel(SCREAMING_SNAKE_CASE	)





     def 				__lowerCAmelCase							(							self						,			SCREAMING_SNAKE_CASE						,			SCREAMING_SNAKE_CASE	) ->				Union[str, Any]:






         """simple docstring"""






         A       :   Dict					=						min(
             self.excesses[from_index]						,			self.graph[from_index][to_index] - self.preflow[from_index][to_index]						,			)
         self.preflow[from_index][to_index] += preflow_delta
         self.preflow[to_index][from_index] -= preflow_delta
         self.excesses[from_index] -= preflow_delta
         self.excesses[to_index] += preflow_delta





     def 				__lowerCAmelCase							(							self						,			SCREAMING_SNAKE_CASE	) ->				int:






         """simple docstring"""






         A       :   Dict					=						None
         for to_index in range(self.verticies_count	):
             if (
                 self.graph[vertex_index][to_index]
                 - self.preflow[vertex_index][to_index]
                 > 0
             ) and (min_height is None or self.heights[to_index] < min_height):
                 A       :   Dict					=						self.heights[to_index]

         if min_height is not None:
             A       :   Dict					=						min_height + 1


if __name__ == "__main__":
      lowercase			:				Optional[int]    		=			[0]
      lowercase			:				List[Any]    		=			[3]
      # graph = [
      #     [0, 0, 4, 6, 0, 0],
      #     [0, 0, 5, 2, 0, 0],
      #     [0, 0, 0, 0, 4, 4],
      #     [0, 0, 0, 0, 6, 6],
      #     [0, 0, 0, 0, 0, 0],
      #     [0, 0, 0, 0, 0, 0],
      # ]
      lowercase			:				int    		=			[[0, 7, 0, 0], [0, 0, 6, 0], [0, 0, 0, 8], [9, 0, 0, 0]]

      # prepare our network
      lowercase			:				List[str]    		=			FlowNetwork(graph, entrances, exits)
      # set algorithm
      flow_network.set_maximum_flow_algorithm(PushRelabelExecutor)
      # and calculate
      lowercase			:				List[str]    		=			flow_network.find_maximum_flow()

      print(f'''maximum flow is {maximum_flow}''')




