

'''simple docstring'''

# This test is meant to be run in on an instance with TPUs like this:
#
#   python examples/pytorch/xla_spawn.py --num_cores=8 tests/test_trainer_tpu.py
#
# Replace 8 with the number of TPU cores you have.
#

import sys
from typing import Dict

from transformers import EvalPrediction, HfArgumentParser, TrainingArguments, is_torch_available
from transformers.utils import logging


a       :      Tuple  	=			logging.get_logger(__name__)


if is_torch_available():
				import torch
				from torch import nn
				from torch.utils.data import Dataset

				from transformers import Trainer







				class   UpperCamelCase__   (       lowercase__       ):


						"""simple docstring"""

						def __init__(			self   ,      snake_case = 1_0_1      ):


											'''simple docstring'''

											UpperCAmelCase		:							Tuple        =       length







						def __len__(			self      ):


											'''simple docstring'''

											return self.length







						def __getitem__(			self   ,      snake_case      ):


											'''simple docstring'''

											return i







				class   UpperCamelCase__   :


						"""simple docstring"""

						def __call__(			self   ,      snake_case      ):


											'''simple docstring'''

											return {"input_ids": torch.tensor(snake_case      ), "labels": torch.tensor(snake_case      )}







				class   UpperCamelCase__   (       nn.Module       ):


						"""simple docstring"""

						def __init__(			self      ):


											'''simple docstring'''

											super().__init__()
											# Add some (unused) params otherwise DDP will complain.
											UpperCAmelCase		:							Dict        =       nn.Linear(1_2_0   ,      8_0      )







						def 				A_	(			self   ,      snake_case   ,      snake_case=None      ):


											'''simple docstring'''

											if labels is not None:
																return torch.tensor(0.0   ,      device=input_ids.device      ), input_ids
											else:
																return input_ids





def 				lowercase (					):



					'''simple docstring'''







					UpperCAmelCase		:							Union[str, Any]        =       HfArgumentParser((TrainingArguments,)							)
					sys.argv += ["--output_dir", "./examples"]
					UpperCAmelCase		:							Optional[Any]        =       parser.parse_args_into_dataclasses()[0]

					logger.warning(
					    F"Process rank: {training_args.local_rank}, device: {training_args.device}, "
					    F"tpu_num_cores: {training_args.tpu_num_cores}"			,   )

					# Essentially, what we want to verify in the distributed case is
					# that we get all samples back, in the right order.
					# (this is crucial for prediction for instance)
					for dataset_length in [1001, 256, 15]:
										UpperCAmelCase		:							Dict        =       DummyDataset(__magic_name__							)

										def compute_metrics(__magic_name__							) -> Dict:
															UpperCAmelCase		:							str        =       list(range(len(__magic_name__							)							)							)
															UpperCAmelCase		:							int        =       p.predictions.tolist() == sequential and p.label_ids.tolist() == sequential
															return {"success": success}

										UpperCAmelCase		:							int        =       Trainer(
										    model=DummyModel()			,   args=__magic_name__			,   data_collator=DummyDataCollator()			,   eval_dataset=__magic_name__			,   compute_metrics=__magic_name__			,   )
										UpperCAmelCase		:							int        =       trainer.evaluate()
										logger.info(__magic_name__							)
										if metrics["eval_success"] is not True:
															logger.error(__magic_name__							)
															exit(1							)

										UpperCAmelCase		:							str        =       trainer.predict(__magic_name__							)
										logger.info(p.metrics							)
										if p.metrics["test_success"] is not True:
															logger.error(p.metrics							)
															exit(1							)

										UpperCAmelCase		:							Any        =       2

										UpperCAmelCase		:							Optional[int]        =       trainer.evaluate()
										logger.info(__magic_name__							)
										if metrics["eval_success"] is not True:
															logger.error(__magic_name__							)
															exit(1							)

										UpperCAmelCase		:							Dict        =       trainer.predict(__magic_name__							)
										logger.info(p.metrics							)
										if p.metrics["test_success"] is not True:
															logger.error(p.metrics							)
															exit(1							)

										UpperCAmelCase		:							str        =       None

					logger.info("🔥 All distributed tests successful"							)





def 				lowercase (					__magic_name__							):



					'''simple docstring'''







					main()


if __name__ == "__main__":
				main()



'''simple docstring'''

from __future__ import annotations







class   UpperCamelCase__   :


		"""simple docstring"""

		def __init__(			self   ,      snake_case      ):


							'''simple docstring'''

							UpperCAmelCase		:							str        =       data
							UpperCAmelCase		:							Dict        =       None







class   UpperCamelCase__   :


		"""simple docstring"""

		def __init__(			self      ):


							'''simple docstring'''

							UpperCAmelCase		:							str        =       None







		def 				A_	(			self   ,      snake_case      ):


							'''simple docstring'''

							UpperCAmelCase		:							int        =       Node(snake_case      )
							UpperCAmelCase		:							Optional[int]        =       self.head
							UpperCAmelCase		:							Union[str, Any]        =       new_node
							return self.head.data







		def 				A_	(			self      ):


							'''simple docstring'''

							UpperCAmelCase		:							Dict        =       self.head
							UpperCAmelCase		:							str        =       self.head
							if self.head:
												while fast_pointer and fast_pointer.next:
																	UpperCAmelCase		:							List[str]        =       fast_pointer.next.next
																	UpperCAmelCase		:							Any        =       slow_pointer.next
												return slow_pointer.data
							else:
												print("No element found."      )
												return None


if __name__ == "__main__":
				a       :      List[str]  	=			LinkedList()
				for _ in range(int(input().strip())):
								a       :      str  	=			int(input().strip())
								link.push(data)
				print(link.middle_element())
