



from random import randint, random




def       __UpperCamelCase      (    _lowerCAmelCase ,	_lowerCAmelCase ,	_lowerCAmelCase ,	_lowerCAmelCase = False ,	_lowerCAmelCase = False ,	_lowerCAmelCase = 5 ,	)			->    list:



    """simple docstring"""






    A					:			Optional[int]		=  [[-1] * number_of_cells]  # Create a highway without any car
    A					:			Any		=  0
    A					:			str		=  max(__UpperCAmelCase ,	0						)
    while i < number_of_cells:
        A					:			Optional[Any]		=  (
            randint(0 ,	__UpperCAmelCase						) if random_speed else initial_speed
        )  # Place the cars
        i += (
            randint(1 ,	max_speed * 2						) if random_frequency else frequency
        )  # Arbitrary number, may need tuning
    return highway




def       __UpperCamelCase      (    _lowerCAmelCase ,	_lowerCAmelCase						)			->    int:



    """simple docstring"""






    A					:			str		=  0
    A					:			Dict		=  highway_now[car_index + 1 :]
    for cell in range(len(__UpperCAmelCase						)						):  # May need a better name for this
        if cells[cell] != -1:  # If the cell is not empty then
            return distance  # we have the distance we wanted
        distance += 1
    # Here if the car is near the end of the highway
    return distance + get_distance(__UpperCAmelCase ,	-1						)




def       __UpperCamelCase      (    _lowerCAmelCase ,	_lowerCAmelCase ,	_lowerCAmelCase						)			->    list:



    """simple docstring"""






    A					:			List[Any]		=  len(__UpperCAmelCase						)
    # Beforce calculations, the highway is empty
    A					:			List[Any]		=  [-1] * number_of_cells

    for car_index in range(__UpperCAmelCase						):
        if highway_now[car_index] != -1:
            # Add 1 to the current speed of the car and cap the speed
            A					:			List[str]		=  min(highway_now[car_index] + 1 ,	__UpperCAmelCase						)
            # Number of empty cell before the next car
            A					:			List[str]		=  get_distance(__UpperCAmelCase ,	__UpperCAmelCase						) - 1
            # We can't have the car causing an accident
            A					:			Union[str, Any]		=  min(next_highway[car_index] ,	__UpperCAmelCase						)
            if random() < probability:
                # Randomly, a driver will slow down
                A					:			Optional[int]		=  max(next_highway[car_index] - 1 ,	0						)
    return next_highway




def       __UpperCamelCase      (    _lowerCAmelCase ,	_lowerCAmelCase ,	_lowerCAmelCase ,	_lowerCAmelCase						)			->    list:



    """simple docstring"""






    A					:			Dict		=  len(highway[0]						)

    for i in range(__UpperCAmelCase						):
        A					:			Tuple		=  update(highway[i] ,	__UpperCAmelCase ,	__UpperCAmelCase						)
        A					:			List[str]		=  [-1] * number_of_cells

        for car_index in range(__UpperCAmelCase						):
            A					:			str		=  next_speeds_calculated[car_index]
            if speed != -1:
                # Change the position based on the speed (with % to create the loop)
                A					:			List[Any]		=  (car_index + speed) % number_of_cells
                # Commit the change of position
                A					:			Any		=  speed
        highway.append(__UpperCAmelCase						)

    return highway


if __name__ == "__main__":
     import doctest

     doctest.testmod()










"""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		(   SCREAMING_SNAKE_CASE_			):
					UpperCAmelCase__								=				"openai/whisper-base"
					UpperCAmelCase__								=				(
					    "This is a tool that transcribes an audio into text. It takes an input named `audio` and returns the "
					    "transcribed text."
					)
					UpperCAmelCase__								=				"transcriber"
					UpperCAmelCase__								=				WhisperProcessor
					UpperCAmelCase__								=				WhisperForConditionalGeneration

					UpperCAmelCase__								=				["audio"]
					UpperCAmelCase__								=				["text"]

					def   lowerCamelCase__   (			self  :      Dict     ,		__snake_case  :      List[str]					)			->							Dict:
											return self.pre_processor(__snake_case     ,		return_tensors="""pt"""					).input_features

					def   lowerCamelCase__   (			self  :      int     ,		__snake_case  :      Union[str, Any]					)			->							List[str]:
											return self.model.generate(inputs=__snake_case					)






					def   lowerCamelCase__   (			self  :      Union[str, Any]     ,		__snake_case  :      List[Any]					)			->							Any:
											return self.pre_processor.batch_decode(__snake_case     ,		skip_special_tokens=__snake_case					)[0]



