






"""simple docstring"""





from random import randint, random







def 	lowerCamelCase__			(				_lowerCamelCase			:						int						,							_lowerCamelCase			:						int						,							_lowerCamelCase			:						int						,							_lowerCamelCase			:						bool = False						,							_lowerCamelCase			:						bool = False						,							_lowerCamelCase			:						int = 5						,							) ->							list:
  lowerCamelCase_       	=		[[-1] * number_of_cells]  # Create a highway without any car
  lowerCamelCase_       	=		0
  lowerCamelCase_       	=		max(_lowerCamelCase						,							0					)
  while i < number_of_cells:
    lowerCamelCase_       	=		(
        randint(0						,							_lowerCamelCase					) 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 	lowerCamelCase__			(				_lowerCamelCase			:						list						,							_lowerCamelCase			:						int					) ->							int:
  lowerCamelCase_       	=		0
  lowerCamelCase_       	=		highway_now[car_index + 1 :]
  for cell in range(len(_lowerCamelCase					)					):  # 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(_lowerCamelCase						,							-1					)







def 	lowerCamelCase__			(				_lowerCamelCase			:						list						,							_lowerCamelCase			:						float						,							_lowerCamelCase			:						int					) ->							list:
  lowerCamelCase_       	=		len(_lowerCamelCase					)
  # Beforce calculations, the highway is empty
  lowerCamelCase_       	=		[-1] * number_of_cells

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







def 	lowerCamelCase__			(				_lowerCamelCase			:						list						,							_lowerCamelCase			:						int						,							_lowerCamelCase			:						float						,							_lowerCamelCase			:						int					) ->							list:
  lowerCamelCase_       	=		len(highway[0]					)

  for i in range(_lowerCamelCase					):
    lowerCamelCase_       	=		update(highway[i]						,							_lowerCamelCase						,							_lowerCamelCase					)
    lowerCamelCase_       	=		[-1] * number_of_cells

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

  return highway


if __name__ == "__main__":
  import doctest

  doctest.testmod()












"""simple docstring"""





import unittest

from datasets import load_dataset

from transformers.pipelines import pipeline
from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow






@is_pipeline_test
@require_torch
class 	a		(   unittest.TestCase						):






    @require_torch
    def   UpperCamelCase			(			self	:				str   )	->						str:
      lowerCamelCase_       	=		pipeline(
          task='zero-shot-audio-classification'			,		model='hf-internal-testing/tiny-clap-htsat-unfused'   )
      lowerCamelCase_       	=		load_dataset('ashraq/esc50'   )
      lowerCamelCase_       	=		dataset['train']['audio'][-1]['array']
      lowerCamelCase_       	=		audio_classifier(__SCREAMING_SNAKE_CASE			,		candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']   )
      self.assertEqual(
          nested_simplify(__SCREAMING_SNAKE_CASE   )			,		[{'score': 0.501, 'label': 'Sound of a dog'}, {'score': 0.499, 'label': 'Sound of vaccum cleaner'}]			,		)






    @unittest.skip('No models are available in TF'   )
    def   UpperCamelCase			(			self	:				Tuple   )	->						Optional[Any]:
      pass






    @slow
    @require_torch
    def   UpperCamelCase			(			self	:				Optional[Any]   )	->						Optional[Any]:
      lowerCamelCase_       	=		pipeline(
          task='zero-shot-audio-classification'			,		model='laion/clap-htsat-unfused'			,		)
      # This is an audio of a dog
      lowerCamelCase_       	=		load_dataset('ashraq/esc50'   )
      lowerCamelCase_       	=		dataset['train']['audio'][-1]['array']
      lowerCamelCase_       	=		audio_classifier(__SCREAMING_SNAKE_CASE			,		candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']   )

      self.assertEqual(
          nested_simplify(__SCREAMING_SNAKE_CASE   )			,		[
              {'score': 0.999, 'label': 'Sound of a dog'},
              {'score': 0.001, 'label': 'Sound of vaccum cleaner'},
          ]			,		)

      lowerCamelCase_       	=		audio_classifier([audio] * 5			,		candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']   )
      self.assertEqual(
          nested_simplify(__SCREAMING_SNAKE_CASE   )			,		[
              [
                  {'score': 0.999, 'label': 'Sound of a dog'},
                  {'score': 0.001, 'label': 'Sound of vaccum cleaner'},
              ],
          ]
          * 5			,		)
      lowerCamelCase_       	=		audio_classifier(
          [audio] * 5			,		candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']			,		batch_size=5   )
      self.assertEqual(
          nested_simplify(__SCREAMING_SNAKE_CASE   )			,		[
              [
                  {'score': 0.999, 'label': 'Sound of a dog'},
                  {'score': 0.001, 'label': 'Sound of vaccum cleaner'},
              ],
          ]
          * 5			,		)






    @unittest.skip('No models are available in TF'   )
    def   UpperCamelCase			(			self	:				Optional[int]   )	->						int:
      pass




