


import unittest

from transformers import SpeechaTextaConfig
from transformers.testing_utils import is_torch_available, require_torch, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
       import torch

       from transformers.models.speech_to_text_a.modeling_speech_to_text_a import (
           SpeechaTextaDecoder,
           SpeechaTextaForCausalLM,
       )


@require_torch
class        A_					:




      '''simple docstring'''


      def __init__(				self:       Tuple						,      a:       List[Any]						,      a:       Union[str, Any]=99						,      a:       Tuple=13						,      a:       Any=16						,      a:       Tuple=7						,      a:       str=True						,      a:       Optional[Any]=True						,      a:       Tuple=True						,      a:       List[str]=False						,      a:       Tuple=True						,      a:       int=2						,      a:       Any=32						,      a:       Tuple=4						,      a:       str=4						,      a:       Dict=30						,      a:       List[str]=0						,      a:       Optional[Any]=1						,      a:       List[str]=2						,      a:       List[str]=None						,      ):
       __lowerCamelCase		:							Union[str, Any]							=						parent
       __lowerCamelCase		:							Optional[int]							=						batch_size
       __lowerCamelCase		:							List[str]							=						decoder_seq_length
       # For common tests
       __lowerCamelCase		:							List[str]							=						self.decoder_seq_length
       __lowerCamelCase		:							Dict							=						is_training
       __lowerCamelCase		:							List[str]							=						use_attention_mask
       __lowerCamelCase		:							List[Any]							=						use_labels

       __lowerCamelCase		:							int							=						vocab_size
       __lowerCamelCase		:							str							=						d_model
       __lowerCamelCase		:							Optional[int]							=						d_model
       __lowerCamelCase		:							Optional[Any]							=						decoder_layers
       __lowerCamelCase		:							Optional[Any]							=						decoder_layers
       __lowerCamelCase		:							Tuple							=						decoder_ffn_dim
       __lowerCamelCase		:							Any							=						decoder_attention_heads
       __lowerCamelCase		:							Any							=						decoder_attention_heads
       __lowerCamelCase		:							int							=						eos_token_id
       __lowerCamelCase		:							List[Any]							=						bos_token_id
       __lowerCamelCase		:							List[str]							=						pad_token_id
       __lowerCamelCase		:							Optional[Any]							=						decoder_start_token_id
       __lowerCamelCase		:							int							=						use_cache
       __lowerCamelCase		:							Dict							=						max_position_embeddings

       __lowerCamelCase		:							int							=						None
       __lowerCamelCase		:							Optional[Any]							=						decoder_seq_length
       __lowerCamelCase		:							Dict							=						2
       __lowerCamelCase		:							Optional[Any]							=						1




      def      _snake_case	(				self:       Union[str, Any]				):
       __lowerCamelCase		:							int							=						ids_tensor([self.batch_size, self.decoder_seq_length]						,      self.vocab_size				)

       __lowerCamelCase		:							int							=						None
       if self.use_attention_mask:
        __lowerCamelCase		:							Tuple							=						ids_tensor([self.batch_size, self.decoder_seq_length]						,      vocab_size=2				)

       __lowerCamelCase		:							int							=						None
       if self.use_labels:
        __lowerCamelCase		:							str							=						ids_tensor([self.batch_size, self.decoder_seq_length]						,      self.vocab_size				)

       __lowerCamelCase		:							Optional[Any]							=						SpeechaTextaConfig(
           vocab_size=self.vocab_size						,      d_model=self.d_model						,      decoder_layers=self.decoder_layers						,      decoder_ffn_dim=self.decoder_ffn_dim						,      decoder_attention_heads=self.decoder_attention_heads						,      eos_token_id=self.eos_token_id						,      bos_token_id=self.bos_token_id						,      use_cache=self.use_cache						,      pad_token_id=self.pad_token_id						,      decoder_start_token_id=self.decoder_start_token_id						,      max_position_embeddings=self.max_position_embeddings						,      )

       return (
           config,
           input_ids,
           attention_mask,
           lm_labels,
       )




      def      _snake_case	(				self:       str						,      a:       str						,      a:       List[str]						,      a:       Any						,      a:       Tuple						,      ):
       __lowerCamelCase		:							int							=						True
       __lowerCamelCase		:							str							=						SpeechaTextaDecoder(config=a				).to(a				).eval()
       __lowerCamelCase		:							Tuple							=						input_ids[:2]

       input_ids[input_ids == 0] += 1
       # first forward pass
       __lowerCamelCase		:							Optional[int]							=						model(a						,      use_cache=a				)
       __lowerCamelCase		:							Optional[Any]							=						model(a				)
       __lowerCamelCase		:							List[Any]							=						model(a						,      use_cache=a				)

       self.parent.assertTrue(len(a				) == len(a				)				)
       self.parent.assertTrue(len(a				) == len(a				) + 1				)

       __lowerCamelCase		:							Optional[Any]							=						outputs['past_key_values']

       # create hypothetical next token and extent to next_input_ids
       __lowerCamelCase		:							Optional[Any]							=						ids_tensor((2, 1)						,      config.vocab_size - 1				) + 1

       # append to next input_ids and
       __lowerCamelCase		:							Optional[int]							=						torch.cat([input_ids, next_tokens]						,      dim=-1				)

       print(a				)

       __lowerCamelCase		:							List[str]							=						model(a				)['last_hidden_state']
       __lowerCamelCase		:							Dict							=						model(a						,      past_key_values=a				)['last_hidden_state']

       # select random slice
       __lowerCamelCase		:							Union[str, Any]							=						ids_tensor((1,)						,      output_from_past.shape[-1]				).item()
       __lowerCamelCase		:							Dict							=						output_from_no_past[:, next_input_ids.shape[-1] - 1, random_slice_idx].detach()
       __lowerCamelCase		:							str							=						output_from_past[:, 0, random_slice_idx].detach()

       # test that outputs are equal for slice
       assert torch.allclose(a						,      a						,      atol=1e-3				)




      def      _snake_case	(				self:       str				):
       __lowerCamelCase		:							Optional[Any]							=						self.prepare_config_and_inputs()
       (
           (
           __lowerCamelCase
       )					,     (
           __lowerCamelCase
       )					,     (
           __lowerCamelCase
       )					,     (
           __lowerCamelCase
       )					,     
       )		:							Tuple							=						config_and_inputs

       __lowerCamelCase		:							List[Any]							=						{
           'input_ids': input_ids,
           'attention_mask': attention_mask,
       }
       return config, inputs_dict



@require_torch
class        A_					(       __UpperCamelCase					,      __UpperCamelCase					,      __UpperCamelCase					,      unittest.TestCase    ):




      '''simple docstring'''


      __snake_case					       =   (SpeechaTextaDecoder, SpeechaTextaForCausalLM) if is_torch_available() else ()
      __snake_case					       =   (SpeechaTextaForCausalLM,) if is_torch_available() else ()
      __snake_case					       =   {"""text-generation""": SpeechaTextaForCausalLM} if is_torch_available() else {}
      __snake_case					       =   True
      __snake_case					       =   False




      def      _snake_case	(				self:       Dict						,      ):
       __lowerCamelCase		:							List[Any]							=						SpeechaTextaStandaloneDecoderModelTester(self						,      is_training=a				)
       __lowerCamelCase		:							List[str]							=						ConfigTester(self						,      config_class=a				)




      def      _snake_case	(				self:       int				):
       pass




      def      _snake_case	(				self:       Any				):
       pass




      def      _snake_case	(				self:       str				):
       pass




      def      _snake_case	(				self:       Optional[Any]				):
       self.config_tester.run_common_tests()




      def      _snake_case	(				self:       List[str]				):
       __lowerCamelCase		:							Any							=						self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_decoder_model_past(*a				)




      def      _snake_case	(				self:       Tuple				):
       return





from __future__ import annotations


class        A_					:




      '''simple docstring'''


      def __init__(				self:       Union[str, Any]						,      a:       int				):
       __lowerCamelCase		:							List[Any]							=						data
       __lowerCamelCase		:							Optional[Any]							=						None



class        A_					:




      '''simple docstring'''


      def __init__(				self:       Dict				):
       __lowerCamelCase		:							Dict							=						None




      def      _snake_case	(				self:       Dict						,      a:       int				):
       __lowerCamelCase		:							List[Any]							=						Node(a				)
       __lowerCamelCase		:							Dict							=						self.head
       __lowerCamelCase		:							Optional[int]							=						new_node
       return self.head.data




      def      _snake_case	(				self:       Optional[Any]				):
       __lowerCamelCase		:							Union[str, Any]							=						self.head
       __lowerCamelCase		:							List[Any]							=						self.head
       if self.head:
        while fast_pointer and fast_pointer.next:
         __lowerCamelCase		:							Any							=						fast_pointer.next.next
         __lowerCamelCase		:							str							=						slow_pointer.next
        return slow_pointer.data
       else:
        print('No element found.'				)
        return None


if __name__ == "__main__":
       lowercase_           =	LinkedList()
       for _ in range(int(input().strip())):
              lowercase_           =	int(input().strip())
              link.push(data)
       print(link.middle_element())

