





import re
import time
from typing import Optional

import IPython.display as disp

from ..trainer_callback import TrainerCallback
from ..trainer_utils import IntervalStrategy, has_length

def    lowerCamelCase_(lowerCamelCase_    ) ->       Optional[Any]:
						UpperCAmelCase         =     int(__lowerCAmelCase    )
						UpperCAmelCase       ,		UpperCAmelCase       ,		UpperCAmelCase         =     t // 3_600, (t // 60) % 60, t % 60
						return F'{h}:{m:02d}:{s:02d}' if h != 0 else F'{m:02d}:{s:02d}'

def    lowerCamelCase_(lowerCamelCase_    ,   lowerCamelCase_    ,   lowerCamelCase_    ,   lowerCamelCase_    ,   lowerCamelCase_=300    ) ->       Optional[Any]:
						return F'\n    <div>\n      {prefix}\n      <progress value=\'{value}\' max=\'{total}\' style=\'width:{width}px; height:20px; vertical-align: middle;\'></progress>\n      {label}\n    </div>\n    '

def    lowerCamelCase_(lowerCamelCase_    ) ->       Tuple:
						UpperCAmelCase         =     "<table border=\"1\" class=\"dataframe\">\n"
						html_code += """  <thead>\n <tr style="text-align: left;">\n"""
						for i in items[0]:
												html_code += F'      <th>{i}</th>\n'
						html_code += "    </tr>\n  </thead>\n  <tbody>\n"
						for line in items[1:]:
												html_code += "    <tr>\n"
												for elt in line:
																		UpperCAmelCase         =     F'{elt:.6f}' if isinstance(__lowerCAmelCase    ,   __lowerCAmelCase    ) else str(__lowerCAmelCase    )
																		html_code += F'      <td>{elt}</td>\n'
												html_code += "    </tr>\n"
						html_code += "  </tbody>\n</table><p>"
						return html_code





class  __magic_name__   :
		lowercase      :       Tuple          =5
		lowercase      :       List[Any]          =0.2






		def __init__(						self      :     str				,		UpperCamelCase__      :     int				,		UpperCamelCase__      :     Optional[str] = None				,		UpperCamelCase__      :     bool = True				,		UpperCamelCase__      :     Optional["NotebookTrainingTracker"] = None				,		UpperCamelCase__      :     int = 3_00				,		)				->					Any:
								'''simple docstring'''







								UpperCAmelCase         =     total
								UpperCAmelCase         =     "" if prefix is None else prefix
								UpperCAmelCase         =     leave
								UpperCAmelCase         =     parent
								UpperCAmelCase         =     width
								UpperCAmelCase         =     None
								UpperCAmelCase         =     None
								UpperCAmelCase         =     None






		def SCREAMING_SNAKE_CASE_			(						self      :     List[str]				,		UpperCamelCase__      :     int				,		UpperCamelCase__      :     bool = False				,		UpperCamelCase__      :     str = None      )				->					Dict:
								'''simple docstring'''







								UpperCAmelCase         =     value
								if comment is not None:
														UpperCAmelCase         =     comment
								if self.last_value is None:
														UpperCAmelCase         =     UpperCAmelCase         =     time.time()
														UpperCAmelCase         =     UpperCAmelCase         =     value
														UpperCAmelCase         =     UpperCAmelCase         =     None
														UpperCAmelCase         =     self.warmup
														UpperCAmelCase         =     1
														self.update_bar(lowerCAmelCase_      )
								elif value <= self.last_value and not force_update:
														return
								elif force_update or self.first_calls > 0 or value >= min(self.last_value + self.wait_for				,		self.total      ):
														if self.first_calls > 0:
																				self.first_calls -= 1
														UpperCAmelCase         =     time.time()
														UpperCAmelCase         =     current_time - self.start_time
														# We could have value = self.start_value if the update is called twixe with the same start value.
														if value > self.start_value:
																				UpperCAmelCase         =     self.elapsed_time / (value - self.start_value)
														else:
																				UpperCAmelCase         =     None
														if value >= self.total:
																				UpperCAmelCase         =     self.total
																				UpperCAmelCase         =     None
																				if not self.leave:
																										self.close()
														elif self.average_time_per_item is not None:
																				UpperCAmelCase         =     self.average_time_per_item * (self.total - value)
														self.update_bar(lowerCAmelCase_      )
														UpperCAmelCase         =     value
														UpperCAmelCase         =     current_time
														if self.average_time_per_item is None:
																				UpperCAmelCase         =     1
														else:
																				UpperCAmelCase         =     max(int(self.update_every / self.average_time_per_item      )				,		1      )






		def SCREAMING_SNAKE_CASE_			(						self      :     Any				,		UpperCamelCase__      :     Any				,		UpperCamelCase__      :     Tuple=None      )				->					Dict:
								'''simple docstring'''







								UpperCAmelCase         =     " " * (len(str(self.total      )      ) - len(str(lowerCAmelCase_      )      )) + str(lowerCAmelCase_      )
								if self.elapsed_time is None:
														UpperCAmelCase         =     F'[{spaced_value}/{self.total} : < :'
								elif self.predicted_remaining is None:
														UpperCAmelCase         =     F'[{spaced_value}/{self.total} {format_time(self.elapsed_time      )}'
								else:
														UpperCAmelCase         =     (
														    F'[{spaced_value}/{self.total} {format_time(self.elapsed_time      )} <'
														    F' {format_time(self.predicted_remaining      )}'
														)
														self.label += F', {1/self.average_time_per_item:.2f} it/s'
								self.label += "]" if self.comment is None or len(self.comment      ) == 0 else F', {self.comment}]'
								self.display()






		def SCREAMING_SNAKE_CASE_			(						self      :     List[Any]      )				->					Any:
								'''simple docstring'''







								UpperCAmelCase         =     html_progress_bar(self.value				,		self.total				,		self.prefix				,		self.label				,		self.width      )
								if self.parent is not None:
														# If this is a child bar, the parent will take care of the display.
														self.parent.display()
														return
								if self.output is None:
														UpperCAmelCase         =     disp.display(disp.HTML(self.html_code      )				,		display_id=lowerCAmelCase_      )
								else:
														self.output.update(disp.HTML(self.html_code      )      )







		def SCREAMING_SNAKE_CASE_			(						self      :     List[Any]      )				->					Tuple:
								'''simple docstring'''







								if self.parent is None and self.output is not None:
														self.output.update(disp.HTML(""      )      )





class  __magic_name__   (							__UpperCAmelCase						):






		def __init__(						self      :     List[Any]				,		UpperCamelCase__      :     Dict				,		UpperCamelCase__      :     List[Any]=None      )				->					int:
								'''simple docstring'''







								super().__init__(lowerCAmelCase_      )
								UpperCAmelCase         =     None if column_names is None else [column_names]
								UpperCAmelCase         =     None






		def SCREAMING_SNAKE_CASE_			(						self      :     Any      )				->					List[Any]:
								'''simple docstring'''







								UpperCAmelCase         =     html_progress_bar(self.value				,		self.total				,		self.prefix				,		self.label				,		self.width      )
								if self.inner_table is not None:
														self.html_code += text_to_html_table(self.inner_table      )
								if self.child_bar is not None:
														self.html_code += self.child_bar.html_code
								if self.output is None:
														UpperCAmelCase         =     disp.display(disp.HTML(self.html_code      )				,		display_id=lowerCAmelCase_      )
								else:
														self.output.update(disp.HTML(self.html_code      )      )






		def SCREAMING_SNAKE_CASE_			(						self      :     Tuple				,		UpperCamelCase__      :     Union[str, Any]      )				->					Dict:
								'''simple docstring'''







								if self.inner_table is None:
														UpperCAmelCase         =     [list(values.keys()      ), list(values.values()      )]
								else:
														UpperCAmelCase         =     self.inner_table[0]
														if len(self.inner_table      ) == 1:
																				# We give a chance to update the column names at the first iteration
																				for key in values.keys():
																										if key not in columns:
																																columns.append(lowerCAmelCase_      )
																				UpperCAmelCase         =     columns
														self.inner_table.append([values[c] for c in columns]      )






		def SCREAMING_SNAKE_CASE_			(						self      :     Optional[int]				,		UpperCamelCase__      :     List[str]				,		UpperCamelCase__      :     Optional[Any]=None				,		UpperCamelCase__      :     int=3_00      )				->					Union[str, Any]:
								'''simple docstring'''







								UpperCAmelCase         =     NotebookProgressBar(lowerCAmelCase_				,		prefix=lowerCAmelCase_				,		parent=self				,		width=lowerCAmelCase_      )
								return self.child_bar







		def SCREAMING_SNAKE_CASE_			(						self      :     Optional[int]      )				->					List[str]:
								'''simple docstring'''







								UpperCAmelCase         =     None
								self.display()





class  __magic_name__   (							__UpperCAmelCase						):






		def __init__(						self      :     List[Any]      )				->					int:
								'''simple docstring'''







								UpperCAmelCase         =     None
								UpperCAmelCase         =     None
								UpperCAmelCase         =     False






		def SCREAMING_SNAKE_CASE_			(						self      :     Any				,		UpperCamelCase__      :     str				,		UpperCamelCase__      :     Any				,		UpperCamelCase__      :     Any				,		**UpperCamelCase__      :     List[str]      )				->					Optional[Any]:
								'''simple docstring'''







								UpperCAmelCase         =     "Epoch" if args.evaluation_strategy == IntervalStrategy.EPOCH else "Step"
								UpperCAmelCase         =     0
								UpperCAmelCase         =     0
								UpperCAmelCase         =     [self.first_column] + ["Training Loss"]
								if args.evaluation_strategy != IntervalStrategy.NO:
														column_names.append("Validation Loss"      )
								UpperCAmelCase         =     NotebookTrainingTracker(state.max_steps				,		lowerCAmelCase_      )






		def SCREAMING_SNAKE_CASE_			(						self      :     Tuple				,		UpperCamelCase__      :     Dict				,		UpperCamelCase__      :     int				,		UpperCamelCase__      :     str				,		**UpperCamelCase__      :     List[Any]      )				->					int:
								'''simple docstring'''







								UpperCAmelCase         =     int(state.epoch      ) if int(state.epoch      ) == state.epoch else F'{state.epoch:.2f}'
								self.training_tracker.update(
								    state.global_step + 1				,		comment=F'Epoch {epoch}/{state.num_train_epochs}'				,		force_update=self._force_next_update				,		)
								UpperCAmelCase         =     False






		def SCREAMING_SNAKE_CASE_			(						self      :     Dict				,		UpperCamelCase__      :     Union[str, Any]				,		UpperCamelCase__      :     int				,		UpperCamelCase__      :     Optional[Any]				,		UpperCamelCase__      :     List[str]=None				,		**UpperCamelCase__      :     Union[str, Any]      )				->					Tuple:
								'''simple docstring'''







								if not has_length(lowerCAmelCase_      ):
														return
								if self.prediction_bar is None:
														if self.training_tracker is not None:
																				UpperCAmelCase         =     self.training_tracker.add_child(len(lowerCAmelCase_      )      )
														else:
																				UpperCAmelCase         =     NotebookProgressBar(len(lowerCAmelCase_      )      )
														self.prediction_bar.update(1      )
								else:
														self.prediction_bar.update(self.prediction_bar.value + 1      )






		def SCREAMING_SNAKE_CASE_			(						self      :     Tuple				,		UpperCamelCase__      :     Optional[int]				,		UpperCamelCase__      :     str				,		UpperCamelCase__      :     int				,		**UpperCamelCase__      :     List[Any]      )				->					Any:
								'''simple docstring'''







								if self.prediction_bar is not None:
														self.prediction_bar.close()
								UpperCAmelCase         =     None






		def SCREAMING_SNAKE_CASE_			(						self      :     Optional[int]				,		UpperCamelCase__      :     int				,		UpperCamelCase__      :     Union[str, Any]				,		UpperCamelCase__      :     Tuple				,		UpperCamelCase__      :     str=None				,		**UpperCamelCase__      :     Any      )				->					Optional[int]:
								'''simple docstring'''







								if args.evaluation_strategy == IntervalStrategy.NO and "loss" in logs:
														UpperCAmelCase         =     {"Training Loss": logs["loss"]}
														# First column is necessarily Step sine we're not in epoch eval strategy
														UpperCAmelCase         =     state.global_step
														self.training_tracker.write_line(lowerCAmelCase_      )






		def SCREAMING_SNAKE_CASE_			(						self      :     int				,		UpperCamelCase__      :     int				,		UpperCamelCase__      :     Union[str, Any]				,		UpperCamelCase__      :     Tuple				,		UpperCamelCase__      :     Dict=None				,		**UpperCamelCase__      :     Tuple      )				->					List[str]:
								'''simple docstring'''







								if self.training_tracker is not None:
														UpperCAmelCase         =     {"Training Loss": "No log", "Validation Loss": "No log"}
														for log in reversed(state.log_history      ):
																				if "loss" in log:
																										UpperCAmelCase         =     log["loss"]
																										break

														if self.first_column == "Epoch":
																				UpperCAmelCase         =     int(state.epoch      )
														else:
																				UpperCAmelCase         =     state.global_step
														UpperCAmelCase         =     "eval"
														for k in metrics:
																				if k.endswith("_loss"      ):
																										UpperCAmelCase         =     re.sub(R"\_loss$"				,		""				,		lowerCAmelCase_      )
														UpperCAmelCase         =     metrics.pop("total_flos"				,		lowerCAmelCase_      )
														UpperCAmelCase         =     metrics.pop("epoch"				,		lowerCAmelCase_      )
														UpperCAmelCase         =     metrics.pop(F'{metric_key_prefix}_runtime'				,		lowerCAmelCase_      )
														UpperCAmelCase         =     metrics.pop(F'{metric_key_prefix}_samples_per_second'				,		lowerCAmelCase_      )
														UpperCAmelCase         =     metrics.pop(F'{metric_key_prefix}_steps_per_second'				,		lowerCAmelCase_      )
														UpperCAmelCase         =     metrics.pop(F'{metric_key_prefix}_jit_compilation_time'				,		lowerCAmelCase_      )
														for k, v in metrics.items():
																				if k == F'{metric_key_prefix}_loss':
																										UpperCAmelCase         =     v
																				else:
																										UpperCAmelCase         =     k.split("_"      )
																										UpperCAmelCase         =     " ".join([part.capitalize() for part in splits[1:]]      )
																										UpperCAmelCase         =     v
														self.training_tracker.write_line(lowerCAmelCase_      )
														self.training_tracker.remove_child()
														UpperCAmelCase         =     None
														# Evaluation takes a long time so we should force the next update.
														UpperCAmelCase         =     True







		def SCREAMING_SNAKE_CASE_			(						self      :     List[Any]				,		UpperCamelCase__      :     Any				,		UpperCamelCase__      :     List[str]				,		UpperCamelCase__      :     Union[str, Any]				,		**UpperCamelCase__      :     Tuple      )				->					Optional[Any]:
								'''simple docstring'''







								self.training_tracker.update(
								    state.global_step				,		comment=F'Epoch {int(state.epoch      )}/{state.num_train_epochs}'				,		force_update=lowerCAmelCase_      )
								UpperCAmelCase         =     None








def    lowerCamelCase_(lowerCamelCase_    ) ->       list[int]:
						UpperCAmelCase         =     len(lowerCamelCase_    )
						for i in range(lowerCamelCase_    ):
												for j in range(i + 1    ,   lowerCamelCase_    ):
																		if numbers[j] < numbers[i]:
																								UpperCAmelCase       ,		UpperCAmelCase         =     numbers[j], numbers[i]
						return numbers


if __name__ == "__main__":
		__lowerCamelCase     :							int  							=				input("Enter numbers separated by a comma:\n").strip()
		__lowerCamelCase     :							Dict  							=				[int(item) for item in user_input.split(",")]
		print(exchange_sort(unsorted))



