




import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin







class     __lowerCAmelCase (       __magic_name__ ):

			"""simple docstring"""







			snake_case_   		=       '''MCTCTFeatureExtractor'''
			snake_case_   		=       '''AutoTokenizer'''


			def __init__(      self			,						lowerCamelCase__			,						lowerCamelCase__							)    ->      Dict:



							'''simple docstring'''
							super().__init__(lowerCamelCase__			,						lowerCamelCase__							)
							__lowerCamelCase		       =    self.feature_extractor
							__lowerCamelCase		       =    False


			def __call__(      self			,						*lowerCamelCase__			,						**lowerCamelCase__							)    ->      Any:



							'''simple docstring'''
							# For backward compatibility
							if self._in_target_context_manager:
											return self.current_processor(*lowerCamelCase__			,						**lowerCamelCase__							)

							if "raw_speech" in kwargs:
											warnings.warn('Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.'							)
											__lowerCamelCase		       =    kwargs.pop('raw_speech'							)
							else:
											__lowerCamelCase		       =    kwargs.pop('audio'			,						lowerCamelCase__							)
							__lowerCamelCase		       =    kwargs.pop('sampling_rate'			,						lowerCamelCase__							)
							__lowerCamelCase		       =    kwargs.pop('text'			,						lowerCamelCase__							)
							if len(lowerCamelCase__							) > 0:
											__lowerCamelCase		       =    args[0]
											__lowerCamelCase		       =    args[1:]

							if audio is None and text is None:
											raise ValueError('You need to specify either an `audio` or `text` input to process.'							)

							if audio is not None:
											__lowerCamelCase		       =    self.feature_extractor(lowerCamelCase__			,						*lowerCamelCase__			,						sampling_rate=lowerCamelCase__			,						**lowerCamelCase__							)
							if text is not None:
											__lowerCamelCase		       =    self.tokenizer(lowerCamelCase__			,						**lowerCamelCase__							)

							if text is None:
											return inputs
							elif audio is None:
											return encodings
							else:
											__lowerCamelCase		       =    encodings['input_ids']
											return inputs


			def       lowercase_    (      self			,						*lowerCamelCase__			,						**lowerCamelCase__							)    ->      int:



							'''simple docstring'''
							return self.tokenizer.batch_decode(*lowerCamelCase__			,						**lowerCamelCase__							)


			def       lowercase_    (      self			,						*lowerCamelCase__			,						**lowerCamelCase__							)    ->      str:



							'''simple docstring'''
							# For backward compatibility
							if self._in_target_context_manager:
											return self.current_processor.pad(*lowerCamelCase__			,						**lowerCamelCase__							)

							__lowerCamelCase		       =    kwargs.pop('input_features'			,						lowerCamelCase__							)
							__lowerCamelCase		       =    kwargs.pop('labels'			,						lowerCamelCase__							)
							if len(lowerCamelCase__							) > 0:
											__lowerCamelCase		       =    args[0]
											__lowerCamelCase		       =    args[1:]

							if input_features is not None:
											__lowerCamelCase		       =    self.feature_extractor.pad(lowerCamelCase__			,						*lowerCamelCase__			,						**lowerCamelCase__							)
							if labels is not None:
											__lowerCamelCase		       =    self.tokenizer.pad(lowerCamelCase__			,						**lowerCamelCase__							)

							if labels is None:
											return input_features
							elif input_features is None:
											return labels
							else:
											__lowerCamelCase		       =    labels['input_ids']
											return input_features


			def       lowercase_    (      self			,						*lowerCamelCase__			,						**lowerCamelCase__							)    ->      List[Any]:



							'''simple docstring'''
							return self.tokenizer.decode(*lowerCamelCase__			,						**lowerCamelCase__							)






			@contextmanager
			def       lowercase_    (      self							)    ->      List[str]:



							'''simple docstring'''
							warnings.warn(
							    '`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your '
							    'labels by using the argument `text` of the regular `__call__` method (either in the same call as '
							    'your audio inputs, or in a separate call.'							)
							__lowerCamelCase		       =    True
							__lowerCamelCase		       =    self.tokenizer
							yield
							__lowerCamelCase		       =    self.feature_extractor
							__lowerCamelCase		       =    False








class     __lowerCAmelCase :

			"""simple docstring"""







			def __init__(      self							)    ->      Any:



							'''simple docstring'''
							__lowerCamelCase		       =    0
							__lowerCamelCase		       =    0
							__lowerCamelCase		       =    {}


			def       lowercase_    (      self			,						lowerCamelCase__							)    ->      Tuple:



							'''simple docstring'''
							if vertex not in self.adjacency:
											__lowerCamelCase		       =    {}
											self.num_vertices += 1


			def       lowercase_    (      self			,						lowerCamelCase__			,						lowerCamelCase__			,						lowerCamelCase__							)    ->      str:



							'''simple docstring'''
							self.add_vertex(lowerCamelCase__							)
							self.add_vertex(lowerCamelCase__							)

							if head == tail:
											return

							__lowerCamelCase		       =    weight
							__lowerCamelCase		       =    weight


			def       lowercase_    (      self							)    ->      List[str]:



							'''simple docstring'''
							__lowerCamelCase		       =    self.get_edges()
							for edge in edges:
											__lowerCamelCase       ,						__lowerCamelCase       ,						__lowerCamelCase		       =    edge
											edges.remove((tail, head, weight)							)
							for i in range(len(lowerCamelCase__							)							):
											__lowerCamelCase		       =    list(edges[i]							)

							edges.sort(key=lambda lowerCamelCase__							: e[2]							)
							for i in range(len(lowerCamelCase__							) - 1							):
											if edges[i][2] >= edges[i + 1][2]:
															__lowerCamelCase		       =    edges[i][2] + 1
							for edge in edges:
											__lowerCamelCase       ,						__lowerCamelCase       ,						__lowerCamelCase		       =    edge
											__lowerCamelCase		       =    weight
											__lowerCamelCase		       =    weight


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



							'''simple docstring'''
							__lowerCamelCase		       =    ''
							for tail in self.adjacency:
											for head in self.adjacency[tail]:
															__lowerCamelCase		       =    self.adjacency[head][tail]
															string += f"""{head} -> {tail} == {weight}\n"""
							return string.rstrip('\n'							)


			def       lowercase_    (      self							)    ->      Optional[Any]:



							'''simple docstring'''
							__lowerCamelCase		       =    []
							for tail in self.adjacency:
											for head in self.adjacency[tail]:
															output.append((tail, head, self.adjacency[head][tail])							)
							return output


			def       lowercase_    (      self							)    ->      List[Any]:



							'''simple docstring'''
							return self.adjacency.keys()


			@staticmethod
			def       lowercase_    (      lowerCamelCase__=None			,						lowerCamelCase__=None							)    ->      str:



							'''simple docstring'''
							__lowerCamelCase		       =    Graph()
							if vertices is None:
											__lowerCamelCase		       =    []
							if edges is None:
											__lowerCamelCase		       =    []
							for vertex in vertices:
											g.add_vertex(lowerCamelCase__							)
							for edge in edges:
											g.add_edge(*lowerCamelCase__							)
							return g







			class     __lowerCAmelCase :

						"""simple docstring"""







						def __init__(      self							)    ->      Tuple:



										'''simple docstring'''
										__lowerCamelCase		       =    {}
										__lowerCamelCase		       =    {}


						def __len__(      self							)    ->      Tuple:



										'''simple docstring'''
										return len(self.parent							)


						def       lowercase_    (      self			,						lowerCamelCase__							)    ->      List[Any]:



										'''simple docstring'''
										if item in self.parent:
														return self.find(lowerCamelCase__							)

										__lowerCamelCase		       =    item
										__lowerCamelCase		       =    0
										return item


						def       lowercase_    (      self			,						lowerCamelCase__							)    ->      List[str]:



										'''simple docstring'''
										if item not in self.parent:
														return self.make_set(lowerCamelCase__							)
										if item != self.parent[item]:
														__lowerCamelCase		       =    self.find(self.parent[item]							)
										return self.parent[item]






						def       lowercase_    (      self			,						lowerCamelCase__			,						lowerCamelCase__							)    ->      int:



										'''simple docstring'''
										__lowerCamelCase		       =    self.find(lowerCamelCase__							)
										__lowerCamelCase		       =    self.find(lowerCamelCase__							)

										if roota == roota:
														return roota

										if self.rank[roota] > self.rank[roota]:
														__lowerCamelCase		       =    roota
														return roota

										if self.rank[roota] < self.rank[roota]:
														__lowerCamelCase		       =    roota
														return roota

										if self.rank[roota] == self.rank[roota]:
														self.rank[roota] += 1
														__lowerCamelCase		       =    roota
														return roota
										return None




			@staticmethod
			def       lowercase_    (      lowerCamelCase__							)    ->      str:



							'''simple docstring'''
							__lowerCamelCase		       =    graph.num_vertices

							__lowerCamelCase		       =    Graph.UnionFind()
							__lowerCamelCase		       =    []
							while num_components > 1:
											__lowerCamelCase		       =    {}
											for vertex in graph.get_vertices():
															__lowerCamelCase		       =    -1

											__lowerCamelCase		       =    graph.get_edges()
											for edge in edges:
															__lowerCamelCase       ,						__lowerCamelCase       ,						__lowerCamelCase		       =    edge
															edges.remove((tail, head, weight)							)
											for edge in edges:
															__lowerCamelCase       ,						__lowerCamelCase       ,						__lowerCamelCase		       =    edge
															__lowerCamelCase		       =    union_find.find(lowerCamelCase__							)
															__lowerCamelCase		       =    union_find.find(lowerCamelCase__							)
															if seta != seta:
																			if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
																							__lowerCamelCase		       =    [head, tail, weight]

																			if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
																							__lowerCamelCase		       =    [head, tail, weight]
											for vertex in cheap_edge:
															if cheap_edge[vertex] != -1:
																			__lowerCamelCase       ,						__lowerCamelCase       ,						__lowerCamelCase		       =    cheap_edge[vertex]
																			if union_find.find(lowerCamelCase__							) != union_find.find(lowerCamelCase__							):
																							union_find.union(lowerCamelCase__			,						lowerCamelCase__							)
																							mst_edges.append(cheap_edge[vertex]							)
																							__lowerCamelCase		       =    num_components - 1
							__lowerCamelCase		       =    Graph.build(edges=lowerCamelCase__							)
							return mst


