


import argparse

import torch

from transformers import (
    WavaVecaFeatureExtractor,
    WavLMConfig,
    WavLMForAudioFrameClassification,
    WavLMForSequenceClassification,
    WavLMForXVector,
    logging,
)


logging.set_verbosity_info()
lowercase_           =	logging.get_logger(__name__)
def       UpperCamelCase__     (  SCREAMING_SNAKE_CASE__			,       SCREAMING_SNAKE_CASE__			,       SCREAMING_SNAKE_CASE__						):
 __lowerCamelCase		:							Any							=						WavLMForSequenceClassification.from_pretrained(SCREAMING_SNAKE_CASE__			,       config=SCREAMING_SNAKE_CASE__						)
 __lowerCamelCase		:							Any							=						downstream_dict['projector.weight']
 __lowerCamelCase		:							Optional[int]							=						downstream_dict['projector.bias']
 __lowerCamelCase		:							str							=						downstream_dict['model.post_net.linear.weight']
 __lowerCamelCase		:							Optional[int]							=						downstream_dict['model.post_net.linear.bias']
 return model
def       UpperCamelCase__     (  SCREAMING_SNAKE_CASE__			,       SCREAMING_SNAKE_CASE__			,       SCREAMING_SNAKE_CASE__						):
 __lowerCamelCase		:							Optional[Any]							=						WavLMForAudioFrameClassification.from_pretrained(SCREAMING_SNAKE_CASE__			,       config=SCREAMING_SNAKE_CASE__						)
 __lowerCamelCase		:							Union[str, Any]							=						downstream_dict['model.linear.weight']
 __lowerCamelCase		:							Tuple							=						downstream_dict['model.linear.bias']
 return model
def       UpperCamelCase__     (  SCREAMING_SNAKE_CASE__			,       SCREAMING_SNAKE_CASE__			,       SCREAMING_SNAKE_CASE__						):
 __lowerCamelCase		:							Dict							=						WavLMForXVector.from_pretrained(SCREAMING_SNAKE_CASE__			,       config=SCREAMING_SNAKE_CASE__						)
 __lowerCamelCase		:							Any							=						downstream_dict['connector.weight']
 __lowerCamelCase		:							Dict							=						downstream_dict['connector.bias']
 for i, kernel_size in enumerate(hf_config.tdnn_kernel						):
  __lowerCamelCase		:							Optional[Any]							=						downstream_dict[
      f'model.framelevel_feature_extractor.module.{i}.kernel.weight'
  ]
  __lowerCamelCase		:							Optional[int]							=						downstream_dict[f'model.framelevel_feature_extractor.module.{i}.kernel.bias']

 __lowerCamelCase		:							str							=						downstream_dict['model.utterancelevel_feature_extractor.linear1.weight']
 __lowerCamelCase		:							Union[str, Any]							=						downstream_dict['model.utterancelevel_feature_extractor.linear1.bias']
 __lowerCamelCase		:							List[str]							=						downstream_dict['model.utterancelevel_feature_extractor.linear2.weight']
 __lowerCamelCase		:							Optional[Any]							=						downstream_dict['model.utterancelevel_feature_extractor.linear2.bias']
 __lowerCamelCase		:							Tuple							=						downstream_dict['objective.W']
 return model
@torch.no_grad()
def       UpperCamelCase__     (  SCREAMING_SNAKE_CASE__			,       SCREAMING_SNAKE_CASE__			,       SCREAMING_SNAKE_CASE__			,       SCREAMING_SNAKE_CASE__						):
 __lowerCamelCase		:							Union[str, Any]							=						torch.load(SCREAMING_SNAKE_CASE__			,       map_location='cpu'						)

 __lowerCamelCase		:							int							=						checkpoint['Downstream']

 __lowerCamelCase		:							Tuple							=						WavLMConfig.from_pretrained(SCREAMING_SNAKE_CASE__						)
 __lowerCamelCase		:							Tuple							=						WavaVecaFeatureExtractor.from_pretrained(
     SCREAMING_SNAKE_CASE__			,       return_attention_mask=SCREAMING_SNAKE_CASE__			,       do_normalize=SCREAMING_SNAKE_CASE__						)

 __lowerCamelCase		:							Tuple							=						hf_config.architectures[0]
 if arch.endswith('ForSequenceClassification'						):
  __lowerCamelCase		:							Optional[int]							=						convert_classification(SCREAMING_SNAKE_CASE__			,       SCREAMING_SNAKE_CASE__			,       SCREAMING_SNAKE_CASE__						)
 elif arch.endswith('ForAudioFrameClassification'						):
  __lowerCamelCase		:							Tuple							=						convert_diarization(SCREAMING_SNAKE_CASE__			,       SCREAMING_SNAKE_CASE__			,       SCREAMING_SNAKE_CASE__						)
 elif arch.endswith('ForXVector'						):
  __lowerCamelCase		:							Union[str, Any]							=						convert_xvector(SCREAMING_SNAKE_CASE__			,       SCREAMING_SNAKE_CASE__			,       SCREAMING_SNAKE_CASE__						)
 else:
  raise NotImplementedError(f'S3PRL weights conversion is not supported for {arch}'						)

 if hf_config.use_weighted_layer_sum:
  __lowerCamelCase		:							Tuple							=						checkpoint['Featurizer']['weights']

 hf_feature_extractor.save_pretrained(SCREAMING_SNAKE_CASE__						)
 hf_model.save_pretrained(SCREAMING_SNAKE_CASE__						)


if __name__ == "__main__":
       lowercase_           =	argparse.ArgumentParser()
       parser.add_argument(
           '--base_model_name', default=None, type=str, help='Name of the huggingface pretrained base model.'
       )
       parser.add_argument('--config_path', default=None, type=str, help='Path to the huggingface classifier config.')
       parser.add_argument('--checkpoint_path', default=None, type=str, help='Path to the s3prl checkpoint.')
       parser.add_argument('--model_dump_path', default=None, type=str, help='Path to the final converted model.')
       lowercase_           =	parser.parse_args()
       convert_saprl_checkpoint(args.base_model_name, args.config_path, args.checkpoint_path, args.model_dump_path)





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())

