





'''simple docstring'''







from __future__ import annotations

from typing import Generic, TypeVar

snake_case_     :       int						=  TypeVar("T")


class 					__a      (Generic[T]     ):

							def __init__(							self							:     List[str]       ,     __magic_name__							:     int   )					->       None:







													"""simple docstring"""
													UpperCAmelCase_			:      Any     						=  data
													UpperCAmelCase_			:      Dict     						=  self
													UpperCAmelCase_			:      List[str]     						=  0





class 					__a      (Generic[T]     ):

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







													"""simple docstring"""
													# map from node name to the node object
													UpperCAmelCase_			:      Optional[Any]     						=  {}

							def     UpperCAmelCase__	(							self							:     str       ,     __magic_name__							:     Tuple   )					->       None:







													"""simple docstring"""
													# create a new set with x as its member
													UpperCAmelCase_			:      List[Any]     						=  DisjointSetTreeNode(lowerCAmelCase_   )

							def     UpperCAmelCase__	(							self							:     Union[str, Any]       ,     __magic_name__							:     Any   )					->       DisjointSetTreeNode[T]:







													"""simple docstring"""
													# find the set x belongs to (with path-compression)
													UpperCAmelCase_			:      Optional[Any]     						=  self.map[data]
													if elem_ref != elem_ref.parent:
																			UpperCAmelCase_			:      str     						=  self.find_set(elem_ref.parent.data   )
													return elem_ref.parent

							def     UpperCAmelCase__	(							self							:     Optional[int]       ,     __magic_name__							:     Dict       ,     __magic_name__							:     Any   )					->       None:







													"""simple docstring"""
													# helper function for union operation
													if nodea.rank > nodea.rank:
																			UpperCAmelCase_			:      Optional[int]     						=  nodea
													else:
																			UpperCAmelCase_			:      List[str]     						=  nodea
																			if nodea.rank == nodea.rank:
																									nodea.rank += 1



							def     UpperCAmelCase__	(							self							:     Tuple       ,     __magic_name__							:     int       ,     __magic_name__							:     Union[str, Any]   )					->       None:







													"""simple docstring"""
													# merge 2 disjoint sets
													self.link(self.find_set(lowerCAmelCase_   )       ,     self.find_set(lowerCAmelCase_   )   )





class 					__a      (Generic[T]     ):

							def __init__(							self							:     int   )					->       None:







													"""simple docstring"""
													# connections: map from the node to the neighbouring nodes (with weights)
													UpperCAmelCase_			:      Optional[Any]     						=  {}

							def     UpperCAmelCase__	(							self							:     Dict       ,     __magic_name__							:     Any   )					->       None:







													"""simple docstring"""
													# add a node ONLY if its not present in the graph
													if node not in self.connections:
																			UpperCAmelCase_			:      Dict     						=  {}

							def     UpperCAmelCase__	(							self							:     Optional[Any]       ,     __magic_name__							:     int       ,     __magic_name__							:     List[str]       ,     __magic_name__							:     List[Any]   )					->       None:







													"""simple docstring"""
													# add an edge with the given weight
													self.add_node(lowerCAmelCase_   )
													self.add_node(lowerCAmelCase_   )
													UpperCAmelCase_			:      Union[str, Any]     						=  weight
													UpperCAmelCase_			:      Union[str, Any]     						=  weight



							def     UpperCAmelCase__	(							self							:     Dict   )					->       GraphUndirectedWeighted[T]:







													"""simple docstring"""
													UpperCAmelCase_			:      int     						=  []
													UpperCAmelCase_			:      Optional[int]     						=  set()
													for start in self.connections:
																			for end in self.connections[start]:
																									if (start, end) not in seen:
																															seen.add((end, start)   )
																															edges.append((start, end, self.connections[start][end])   )
													edges.sort(key=lambda __magic_name__   : x[2]   )

													# creating the disjoint set
													UpperCAmelCase_			:      int     						=  DisjointSetTree[T]()
													for node in self.connections:
																			disjoint_set.make_set(lowerCAmelCase_   )

													# MST generation
													UpperCAmelCase_			:      Tuple     						=  0
													UpperCAmelCase_			:      str     						=  0
													UpperCAmelCase_			:      Optional[int]     						=  GraphUndirectedWeighted[T]()
													while num_edges < len(self.connections   ) - 1:
																			UpperCAmelCase_						,       UpperCAmelCase_						,       UpperCAmelCase_			:      Dict     						=  edges[index]
																			index += 1
																			UpperCAmelCase_			:      int     						=  disjoint_set.find_set(lowerCAmelCase_   )
																			UpperCAmelCase_			:      Optional[int]     						=  disjoint_set.find_set(lowerCAmelCase_   )
																			if parent_u != parent_v:
																									num_edges += 1
																									graph.add_edge(lowerCAmelCase_       ,     lowerCAmelCase_       ,     lowerCAmelCase_   )
																									disjoint_set.union(lowerCAmelCase_       ,     lowerCAmelCase_   )
													return graph












'''simple docstring'''







# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ..models.whisper import WhisperForConditionalGeneration, WhisperProcessor
from .base import PipelineTool


class 					__a      (lowerCamelCase     ):
							__a					:   List[Any]									=       "openai/whisper-base"
							__a					:   Optional[Any]									=       (
							    "This is a tool that transcribes an audio into text. It takes an input named `audio` and returns the "
							    "transcribed text."
							)
							__a					:   Any									=       "transcriber"
							__a					:   str									=       WhisperProcessor
							__a					:   List[Any]									=       WhisperForConditionalGeneration

							__a					:   int									=       ["audio"]
							__a					:   Optional[Any]									=       ["text"]

							def     UpperCAmelCase__	(							self							:     Dict       ,     __magic_name__							:     List[str]   )					->       Optional[int]:







													"""simple docstring"""
													return self.pre_processor(__magic_name__       ,     return_tensors='''pt'''   ).input_features

							def     UpperCAmelCase__	(							self							:     Dict       ,     __magic_name__							:     Dict   )					->       Tuple:







													"""simple docstring"""
													return self.model.generate(inputs=__magic_name__   )



							def     UpperCAmelCase__	(							self							:     List[str]       ,     __magic_name__							:     Dict   )					->       str:







													"""simple docstring"""
													return self.pre_processor.batch_decode(__magic_name__       ,     skip_special_tokens=__magic_name__   )[0]





