



'''simple docstring'''



from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCamelCase									=							logging.get_logger(__name__)

lowerCamelCase									=							{}





class _UpperCamelCase		(  a__		):





				'''simple docstring'''





				lowerCAmelCase__            =     """llama"""
				lowerCAmelCase__            =     ["""past_key_values"""]

				def __init__(				self	:	List[str]	,							_lowerCAmelCase	:	Optional[Any]=3_2_0_0_0	,							_lowerCAmelCase	:	Union[str, Any]=4_0_9_6	,							_lowerCAmelCase	:	List[Any]=1_1_0_0_8	,							_lowerCAmelCase	:	str=3_2	,							_lowerCAmelCase	:	Optional[int]=3_2	,							_lowerCAmelCase	:	Optional[int]=None	,							_lowerCAmelCase	:	Any="silu"	,							_lowerCAmelCase	:	List[str]=2_0_4_8	,							_lowerCAmelCase	:	Optional[int]=0.02	,							_lowerCAmelCase	:	Tuple=1e-6	,							_lowerCAmelCase	:	Optional[Any]=True	,							_lowerCAmelCase	:	str=0	,							_lowerCAmelCase	:	str=1	,							_lowerCAmelCase	:	Dict=2	,							_lowerCAmelCase	:	Optional[Any]=1	,							_lowerCAmelCase	:	List[str]=False	,							_lowerCAmelCase	:	str=None	,							**_lowerCAmelCase	:	Any	,							):







											'''simple docstring'''

											__lowercase													=vocab_size
											__lowercase													=max_position_embeddings
											__lowercase													=hidden_size
											__lowercase													=intermediate_size
											__lowercase													=num_hidden_layers
											__lowercase													=num_attention_heads

											# for backward compatibility
											if num_key_value_heads is None:
																		__lowercase													=num_attention_heads

											__lowercase													=num_key_value_heads
											__lowercase													=hidden_act
											__lowercase													=initializer_range
											__lowercase													=rms_norm_eps
											__lowercase													=pretraining_tp
											__lowercase													=use_cache
											__lowercase													=rope_scaling
											self._rope_scaling_validation()

											super().__init__(
											    pad_token_id=lowerCAmelCase__	,							bos_token_id=lowerCAmelCase__	,							eos_token_id=lowerCAmelCase__	,							tie_word_embeddings=lowerCAmelCase__	,							**lowerCAmelCase__	,							)

				def 					__lowerCamelCase  (				self	:	Dict):







											'''simple docstring'''

											if self.rope_scaling is None:
																		return

											if not isinstance(self.rope_scaling	,							lowerCAmelCase__) or len(self.rope_scaling) != 2:
																		raise ValueError(
																		    '`rope_scaling` must be a dictionary with with two fields, `name` and `factor`, '
																		    f"""got {self.rope_scaling}""")
											__lowercase													=self.rope_scaling.get('type'	,							lowerCAmelCase__)
											__lowercase													=self.rope_scaling.get('factor'	,							lowerCAmelCase__)
											if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
																		raise ValueError(
																		    f"""`rope_scaling`'s name field must be one of ['linear', 'dynamic'], got {rope_scaling_type}""")
											if rope_scaling_factor is None or not isinstance(lowerCAmelCase__	,							lowerCAmelCase__) or rope_scaling_factor <= 1.0:
																		raise ValueError(f"""`rope_scaling`'s factor field must be an float > 1, got {rope_scaling_factor}""")










"""simple docstring"""




from __future__ import annotations

from statistics import mean






def  _SCREAMING_SNAKE_CASE						(      _lowercase		:       list[int]       ,			_lowercase		:       list[int]       ,			_lowercase		:       int   )					->list[int]:






	'''simple docstring'''






	a :						Union[str, Any]      =							[0] * no_of_processes
	a :						int      =							[0] * no_of_processes

	# Initialize remaining_time to waiting_time.

	for i in range(_lowercase   ):
		a :						List[Any]      =							burst_time[i]
	a :						list[int]      =							[]

	a :						List[Any]      =							0
	a :						Any      =							0

	# When processes are not completed,
	# A process whose arrival time has passed \
	# and has remaining execution time is put into the ready_process.
	# The shortest process in the ready_process, target_process is executed.

	while completed != no_of_processes:
		a :						str      =							[]
		a :						Tuple      =							-1

		for i in range(_lowercase   ):
			if (arrival_time[i] <= total_time) and (remaining_time[i] > 0):
				ready_process.append(_lowercase   )

		if len(_lowercase   ) > 0:
			a :						List[Any]      =							ready_process[0]
			for i in ready_process:
				if remaining_time[i] < remaining_time[target_process]:
					a :						Optional[Any]      =							i
			total_time += burst_time[target_process]
			completed += 1
			a :						str      =							0
			a :						Union[str, Any]      =							(
			    total_time - arrival_time[target_process] - burst_time[target_process]
			)
		else:
			total_time += 1

	return waiting_time






def  _SCREAMING_SNAKE_CASE						(      _lowercase		:       list[int]       ,			_lowercase		:       int       ,			_lowercase		:       list[int]   )					->list[int]:






	'''simple docstring'''






	a :						List[str]      =							[0] * no_of_processes
	for i in range(_lowercase   ):
		a :						Optional[int]      =							burst_time[i] + waiting_time[i]
	return turn_around_time


if __name__ == "__main__":
		print('''[TEST CASE 01]''')

		a		:					Dict	      =     4
		a		:					Tuple	      =     [2, 5, 3, 7]
		a		:					List[Any]	      =     [0, 0, 0, 0]
		a		:					int	      =     calculate_waitingtime(arrival_time, burst_time, no_of_processes)
		a		:					List[Any]	      =     calculate_turnaroundtime(
		    burst_time, no_of_processes, waiting_time
		)

		# Printing the Result
		print('''PID\tBurst Time\tArrival Time\tWaiting Time\tTurnaround Time''')
		for i, process_id in enumerate(list(range(1, 5))):
				print(
				    F'''{process_id}\t{burst_time[i]}\t\t\t{arrival_time[i]}\t\t\t\t'''
				    F'''{waiting_time[i]}\t\t\t\t{turn_around_time[i]}'''
				)
		print(F'''\nAverage waiting time = {mean(waiting_time):.5f}''')
		print(F'''Average turnaround time = {mean(turn_around_time):.5f}''')


