





import unittest

from diffusers.pipelines.pipeline_utils import is_safetensors_compatible







class     __snake_case       (							unittest.TestCase			):





       '''simple docstring'''







       def 							UpperCAmelCase__ (  self :    str		):
         __snake_case:						Tuple   =						[
             """safety_checker/pytorch_model.bin""",
             """safety_checker/model.safetensors""",
             """vae/diffusion_pytorch_model.bin""",
             """vae/diffusion_pytorch_model.safetensors""",
             """text_encoder/pytorch_model.bin""",
             """text_encoder/model.safetensors""",
             """unet/diffusion_pytorch_model.bin""",
             """unet/diffusion_pytorch_model.safetensors""",
         ]
         self.assertTrue(is_safetensors_compatible(A		)		)




       def 							UpperCAmelCase__ (  self :    int		):
         __snake_case:						Optional[Any]   =						[
             """unet/diffusion_pytorch_model.bin""",
             """unet/diffusion_pytorch_model.safetensors""",
         ]
         self.assertTrue(is_safetensors_compatible(A		)		)




       def 							UpperCAmelCase__ (  self :    Any		):
         __snake_case:						Union[str, Any]   =						[
             """safety_checker/pytorch_model.bin""",
             """safety_checker/model.safetensors""",
             """vae/diffusion_pytorch_model.bin""",
             """vae/diffusion_pytorch_model.safetensors""",
             """text_encoder/pytorch_model.bin""",
             """text_encoder/model.safetensors""",
             """unet/diffusion_pytorch_model.bin""",
             # Removed: 'unet/diffusion_pytorch_model.safetensors',
         ]
         self.assertFalse(is_safetensors_compatible(A		)		)




       def 							UpperCAmelCase__ (  self :    Any		):
         __snake_case:						List[str]   =						[
             """text_encoder/pytorch_model.bin""",
             """text_encoder/model.safetensors""",
         ]
         self.assertTrue(is_safetensors_compatible(A		)		)




       def 							UpperCAmelCase__ (  self :    Tuple		):
         __snake_case:						Optional[Any]   =						[
             """safety_checker/pytorch_model.bin""",
             """safety_checker/model.safetensors""",
             """vae/diffusion_pytorch_model.bin""",
             """vae/diffusion_pytorch_model.safetensors""",
             """text_encoder/pytorch_model.bin""",
             # Removed: 'text_encoder/model.safetensors',
             """unet/diffusion_pytorch_model.bin""",
             """unet/diffusion_pytorch_model.safetensors""",
         ]
         self.assertFalse(is_safetensors_compatible(A		)		)




       def 							UpperCAmelCase__ (  self :    str		):
         __snake_case:						Tuple   =						[
             """safety_checker/pytorch_model.fp16.bin""",
             """safety_checker/model.fp16.safetensors""",
             """vae/diffusion_pytorch_model.fp16.bin""",
             """vae/diffusion_pytorch_model.fp16.safetensors""",
             """text_encoder/pytorch_model.fp16.bin""",
             """text_encoder/model.fp16.safetensors""",
             """unet/diffusion_pytorch_model.fp16.bin""",
             """unet/diffusion_pytorch_model.fp16.safetensors""",
         ]
         __snake_case:						Dict   =						"""fp16"""
         self.assertTrue(is_safetensors_compatible(A							,				variant=A		)		)




       def 							UpperCAmelCase__ (  self :    int		):
         __snake_case:						Dict   =						[
             """unet/diffusion_pytorch_model.fp16.bin""",
             """unet/diffusion_pytorch_model.fp16.safetensors""",
         ]
         __snake_case:						List[str]   =						"""fp16"""
         self.assertTrue(is_safetensors_compatible(A							,				variant=A		)		)




       def 							UpperCAmelCase__ (  self :    List[str]		):
         # pass variant but use the non-variant filenames
         __snake_case:						Any   =						[
             """unet/diffusion_pytorch_model.bin""",
             """unet/diffusion_pytorch_model.safetensors""",
         ]
         __snake_case:						int   =						"""fp16"""
         self.assertTrue(is_safetensors_compatible(A							,				variant=A		)		)




       def 							UpperCAmelCase__ (  self :    Tuple		):
         __snake_case:						Tuple   =						[
             """safety_checker/pytorch_model.fp16.bin""",
             """safety_checker/model.fp16.safetensors""",
             """vae/diffusion_pytorch_model.fp16.bin""",
             """vae/diffusion_pytorch_model.fp16.safetensors""",
             """text_encoder/pytorch_model.fp16.bin""",
             """text_encoder/model.fp16.safetensors""",
             """unet/diffusion_pytorch_model.fp16.bin""",
             # Removed: 'unet/diffusion_pytorch_model.fp16.safetensors',
         ]
         __snake_case:						List[Any]   =						"""fp16"""
         self.assertFalse(is_safetensors_compatible(A							,				variant=A		)		)




       def 							UpperCAmelCase__ (  self :    str		):
         __snake_case:						int   =						[
             """text_encoder/pytorch_model.fp16.bin""",
             """text_encoder/model.fp16.safetensors""",
         ]
         __snake_case:						Any   =						"""fp16"""
         self.assertTrue(is_safetensors_compatible(A							,				variant=A		)		)




       def 							UpperCAmelCase__ (  self :    Union[str, Any]		):
         # pass variant but use the non-variant filenames
         __snake_case:						Any   =						[
             """text_encoder/pytorch_model.bin""",
             """text_encoder/model.safetensors""",
         ]
         __snake_case:						List[str]   =						"""fp16"""
         self.assertTrue(is_safetensors_compatible(A							,				variant=A		)		)






       def 							UpperCAmelCase__ (  self :    List[Any]		):
         __snake_case:						Any   =						[
             """safety_checker/pytorch_model.fp16.bin""",
             """safety_checker/model.fp16.safetensors""",
             """vae/diffusion_pytorch_model.fp16.bin""",
             """vae/diffusion_pytorch_model.fp16.safetensors""",
             """text_encoder/pytorch_model.fp16.bin""",
             # 'text_encoder/model.fp16.safetensors',
             """unet/diffusion_pytorch_model.fp16.bin""",
             """unet/diffusion_pytorch_model.fp16.safetensors""",
         ]
         __snake_case:						List[Any]   =						"""fp16"""
         self.assertFalse(is_safetensors_compatible(A							,				variant=A		)		)













from statistics import mean

import numpy as np







def 			A__							(    SCREAMING_SNAKE_CASE__					,					SCREAMING_SNAKE_CASE__					,					SCREAMING_SNAKE_CASE__					,					SCREAMING_SNAKE_CASE__)   ->    list:
  __snake_case:						List[Any]   =						0
  # Number of processes finished
  __snake_case:						Union[str, Any]   =						0
  # Displays the finished process.
  # If it is 0, the performance is completed if it is 1, before the performance.
  __snake_case:						Dict   =						[0] * no_of_process
  # List to include calculation results
  __snake_case:						Tuple   =						[0] * no_of_process

  # Sort by arrival time.
  __snake_case:						int   =						[burst_time[i] for i in np.argsort(SCREAMING_SNAKE_CASE__)]
  __snake_case:						Any   =						[process_name[i] for i in np.argsort(SCREAMING_SNAKE_CASE__)]
  arrival_time.sort()

  while no_of_process > finished_process_count:
    __snake_case:						Tuple   =						0
    while finished_process[i] == 1:
      i += 1
    if current_time < arrival_time[i]:
      __snake_case:						Any   =						arrival_time[i]

    __snake_case:						List[Any]   =						0
    # Index showing the location of the process being performed
    __snake_case:						Union[str, Any]   =						0
    # Saves the current response ratio.
    __snake_case:						Optional[Any]   =						0
    for i in range(0					,					SCREAMING_SNAKE_CASE__):
      if finished_process[i] == 0 and arrival_time[i] <= current_time:
        __snake_case:						Tuple   =						(burst_time[i] + (current_time - arrival_time[i])) / burst_time[
            i
        ]
      if response_ratio < temp:
        __snake_case:						Union[str, Any]   =						temp
        __snake_case:						Optional[int]   =						i

        # Calculate the turn around time
    __snake_case:						Optional[Any]   =						current_time + burst_time[loc] - arrival_time[loc]
    current_time += burst_time[loc]
    # Indicates that the process has been performed.
    __snake_case:						Optional[int]   =						1
    # Increase finished_process_count by 1
    finished_process_count += 1

  return turn_around_time







def 			A__							(    SCREAMING_SNAKE_CASE__					,					SCREAMING_SNAKE_CASE__					,					SCREAMING_SNAKE_CASE__					,					SCREAMING_SNAKE_CASE__)   ->    list:
  __snake_case:						Union[str, Any]   =						[0] * no_of_process
  for i in range(0					,					SCREAMING_SNAKE_CASE__):
    __snake_case:						Optional[int]   =						turn_around_time[i] - burst_time[i]
  return waiting_time


if __name__ == "__main__":
      __UpperCAmelCase       :   Optional[Any]				       =							5
      __UpperCAmelCase       :   Tuple				       =							["A", "B", "C", "D", "E"]
      __UpperCAmelCase       :   str				       =							[1, 2, 3, 4, 5]
      __UpperCAmelCase       :   Dict				       =							[1, 2, 3, 4, 5]

      __UpperCAmelCase       :   List[str]				       =							calculate_turn_around_time(
          process_name, arrival_time, burst_time, no_of_process
      )
      __UpperCAmelCase       :   List[str]				       =							calculate_waiting_time(
          process_name, turn_around_time, burst_time, no_of_process
      )

      print("Process name \tArrival time \tBurst time \tTurn around time \tWaiting time")
      for i in range(0, no_of_process):
            print(
                f'{process_name[i]}\t\t{arrival_time[i]}\t\t{burst_time[i]}\t\t'
                f'{turn_around_time[i]}\t\t\t{waiting_time[i]}'
            )

      print(f'average waiting time : {mean(waiting_time):.5f}')
      print(f'average turn around time : {mean(turn_around_time):.5f}')






