



"""simple docstring"""





import argparse

import torch

from transformers import (
    UniSpeechSatConfig,
    UniSpeechSatForAudioFrameClassification,
    UniSpeechSatForSequenceClassification,
    UniSpeechSatForXVector,
    WavaVecaFeatureExtractor,
    logging,
)


logging.set_verbosity_info()
lowerCamelCase      =		logging.get_logger(__name__)
def      a__			(   lowerCAmelCase__			,    lowerCAmelCase__			,    lowerCAmelCase__   ):
						UpperCAmelCase_    				=							UniSpeechSatForSequenceClassification.from_pretrained(lowerCAmelCase__			,    config=lowerCAmelCase__   )
						UpperCAmelCase_    				=							downstream_dict["projector.weight"]
						UpperCAmelCase_    				=							downstream_dict["projector.bias"]
						UpperCAmelCase_    				=							downstream_dict["model.post_net.linear.weight"]
						UpperCAmelCase_    				=							downstream_dict["model.post_net.linear.bias"]
						return model
def      a__			(   lowerCAmelCase__			,    lowerCAmelCase__			,    lowerCAmelCase__   ):
						UpperCAmelCase_    				=							UniSpeechSatForAudioFrameClassification.from_pretrained(lowerCAmelCase__			,    config=lowerCAmelCase__   )
						UpperCAmelCase_    				=							downstream_dict["model.linear.weight"]
						UpperCAmelCase_    				=							downstream_dict["model.linear.bias"]
						return model
def      a__			(   lowerCAmelCase__			,    lowerCAmelCase__			,    lowerCAmelCase__   ):
						UpperCAmelCase_    				=							UniSpeechSatForXVector.from_pretrained(lowerCAmelCase__			,    config=lowerCAmelCase__   )
						UpperCAmelCase_    				=							downstream_dict["connector.weight"]
						UpperCAmelCase_    				=							downstream_dict["connector.bias"]
						for i, kernel_size in enumerate(hf_config.tdnn_kernel   ):
												UpperCAmelCase_    				=							downstream_dict[
												    f"""model.framelevel_feature_extractor.module.{i}.kernel.weight"""
												]
												UpperCAmelCase_    				=							downstream_dict[f"""model.framelevel_feature_extractor.module.{i}.kernel.bias"""]

						UpperCAmelCase_    				=							downstream_dict["model.utterancelevel_feature_extractor.linear1.weight"]
						UpperCAmelCase_    				=							downstream_dict["model.utterancelevel_feature_extractor.linear1.bias"]
						UpperCAmelCase_    				=							downstream_dict["model.utterancelevel_feature_extractor.linear2.weight"]
						UpperCAmelCase_    				=							downstream_dict["model.utterancelevel_feature_extractor.linear2.bias"]
						UpperCAmelCase_    				=							downstream_dict["objective.W"]
						return model
@torch.no_grad()
def      a__			(   lowerCAmelCase__			,    lowerCAmelCase__			,    lowerCAmelCase__			,    lowerCAmelCase__   ):
						UpperCAmelCase_    				=							torch.load(lowerCAmelCase__			,    map_location="cpu"   )

						UpperCAmelCase_    				=							checkpoint["Downstream"]

						UpperCAmelCase_    				=							UniSpeechSatConfig.from_pretrained(lowerCAmelCase__   )
						UpperCAmelCase_    				=							WavaVecaFeatureExtractor.from_pretrained(
						    lowerCAmelCase__			,    return_attention_mask=lowerCAmelCase__			,    do_normalize=lowerCAmelCase__   )

						UpperCAmelCase_    				=							hf_config.architectures[0]
						if arch.endswith("ForSequenceClassification"   ):
												UpperCAmelCase_    				=							convert_classification(lowerCAmelCase__			,    lowerCAmelCase__			,    lowerCAmelCase__   )
						elif arch.endswith("ForAudioFrameClassification"   ):
												UpperCAmelCase_    				=							convert_diarization(lowerCAmelCase__			,    lowerCAmelCase__			,    lowerCAmelCase__   )
						elif arch.endswith("ForXVector"   ):
												UpperCAmelCase_    				=							convert_xvector(lowerCAmelCase__			,    lowerCAmelCase__			,    lowerCAmelCase__   )
						else:
												raise NotImplementedError(f"""S3PRL weights conversion is not supported for {arch}"""   )

						if hf_config.use_weighted_layer_sum:
												UpperCAmelCase_    				=							checkpoint["Featurizer"]["weights"]

						hf_feature_extractor.save_pretrained(lowerCAmelCase__   )
						hf_model.save_pretrained(lowerCAmelCase__   )


if __name__ == "__main__":
		lowerCamelCase      =		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.""")
		lowerCamelCase      =		parser.parse_args()
		convert_saprl_checkpoint(args.base_model_name, args.config_path, args.checkpoint_path, args.model_dump_path)









"""simple docstring"""





from __future__ import annotations

import math
def      a__			(   lowerCAmelCase__   ):

      if 1 < number < 4:
            # 2 and 3 are primes
            return True
      elif number < 2 or number % 2 == 0 or number % 3 == 0:
            # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
            return False

      # All primes number are in format of 6k +/- 1
      for i in range(5			,    int(math.sqrt(lowerCAmelCase__   ) + 1   )			,    6   ):
            if number % i == 0 or number % (i + 2) == 0:
                  return False
      return True


lowerCamelCase      =		[num for num in range(3, 100_001, 2) if not is_prime(num)]
def      a__			(   lowerCAmelCase__   ):
      if not isinstance(lowerCAmelCase__			,    lowerCAmelCase__   ):
            raise ValueError("n must be an integer"   )
      if n <= 0:
            raise ValueError("n must be >= 0"   )

      UpperCAmelCase_    				=							[]
      for num in range(len(lowerCAmelCase__   )   ):
            UpperCAmelCase_    				=							0
            while 2 * i * i <= odd_composites[num]:
                  UpperCAmelCase_    				=							odd_composites[num] - 2 * i * i
                  if is_prime(lowerCAmelCase__   ):
                        break
                  i += 1
            else:
                  list_nums.append(odd_composites[num]   )
                  if len(lowerCAmelCase__   ) == n:
                        return list_nums

      return []
def      a__			(   ):
      return compute_nums(1   )[0]


if __name__ == "__main__":
  print(F"{solution() = }")




