


'''simple docstring'''



import argparse

import torch
from flax.training.checkpoints import restore_checkpoint

from transformers import FNetConfig, FNetForPreTraining
from transformers.utils import logging


logging.set_verbosity_info()



def       UpperCAmelCase__ (     UpperCAmelCase_   :    List[Any]				,   UpperCAmelCase_   :    Optional[Any]				,   UpperCAmelCase_   :    Dict							)					->		List[str]:
     # Initialise PyTorch model
     __lowerCamelCase       :     Union[str, Any]        =		FNetConfig.from_json_file(UpperCAmelCase_							)
     print(F'Building PyTorch model from configuration: {config}'							)
     __lowerCamelCase       :     List[str]        =		FNetForPreTraining(UpperCAmelCase_							)

     __lowerCamelCase       :     Optional[Any]        =		restore_checkpoint(UpperCAmelCase_				,   UpperCAmelCase_							)
     __lowerCamelCase       :     List[str]        =		checkpoint_dict['target']

     # Embeddings
     # Position IDs
     __lowerCamelCase       :     Union[str, Any]        =		fnet_pretraining_model.state_dict()

     __lowerCamelCase       :     Dict        =		state_dict['fnet.embeddings.position_ids']
     __lowerCamelCase       :     Union[str, Any]        =		{'fnet.embeddings.position_ids': position_ids}
     # Embedding Layers
     __lowerCamelCase       :     Any        =		torch.tensor(
         pretrained_model_params['encoder']['embedder']['word']['embedding']							)
     __lowerCamelCase       :     Dict        =		torch.tensor(
         pretrained_model_params['encoder']['embedder']['position']['embedding'][0]							)
     __lowerCamelCase       :     Any        =		torch.tensor(
         pretrained_model_params['encoder']['embedder']['type']['embedding']							)
     __lowerCamelCase       :     str        =		torch.tensor(
         pretrained_model_params['encoder']['embedder']['hidden_mapping_in']['kernel']							).T
     __lowerCamelCase       :     List[Any]        =		torch.tensor(
         pretrained_model_params['encoder']['embedder']['hidden_mapping_in']['bias']							)
     __lowerCamelCase       :     str        =		torch.tensor(
         pretrained_model_params['encoder']['embedder']['layer_norm']['scale']							)
     __lowerCamelCase       :     Union[str, Any]        =		torch.tensor(
         pretrained_model_params['encoder']['embedder']['layer_norm']['bias']							)

     # Encoder Layers
     for layer in range(config.num_hidden_layers							):
          __lowerCamelCase       :     Optional[Any]        =		torch.tensor(
              pretrained_model_params['encoder'][F'encoder_{layer}']['mixing_layer_norm']['scale']							)
          __lowerCamelCase       :     Optional[Any]        =		torch.tensor(
              pretrained_model_params['encoder'][F'encoder_{layer}']['mixing_layer_norm']['bias']							)

          __lowerCamelCase       :     int        =		torch.tensor(
              pretrained_model_params['encoder'][F'feed_forward_{layer}']['intermediate']['kernel']							).T
          __lowerCamelCase       :     Dict        =		torch.tensor(
              pretrained_model_params['encoder'][F'feed_forward_{layer}']['intermediate']['bias']							)

          __lowerCamelCase       :     List[str]        =		torch.tensor(
              pretrained_model_params['encoder'][F'feed_forward_{layer}']['output']['kernel']							).T
          __lowerCamelCase       :     Any        =		torch.tensor(
              pretrained_model_params['encoder'][F'feed_forward_{layer}']['output']['bias']							)

          __lowerCamelCase       :     List[str]        =		torch.tensor(
              pretrained_model_params['encoder'][F'encoder_{layer}']['output_layer_norm']['scale']							)
          __lowerCamelCase       :     Optional[int]        =		torch.tensor(
              pretrained_model_params['encoder'][F'encoder_{layer}']['output_layer_norm']['bias']							)

     # Pooler Layers
     __lowerCamelCase       :     str        =		torch.tensor(pretrained_model_params['encoder']['pooler']['kernel']							).T
     __lowerCamelCase       :     Any        =		torch.tensor(pretrained_model_params['encoder']['pooler']['bias']							)

     # Masked LM Layers
     __lowerCamelCase       :     Union[str, Any]        =		torch.tensor(
         pretrained_model_params['predictions_dense']['kernel']							).T
     __lowerCamelCase       :     Optional[Any]        =		torch.tensor(
         pretrained_model_params['predictions_dense']['bias']							)
     __lowerCamelCase       :     str        =		torch.tensor(
         pretrained_model_params['predictions_layer_norm']['scale']							)
     __lowerCamelCase       :     List[Any]        =		torch.tensor(
         pretrained_model_params['predictions_layer_norm']['bias']							)
     __lowerCamelCase       :     List[str]        =		torch.tensor(
         pretrained_model_params['encoder']['embedder']['word']['embedding']							)
     __lowerCamelCase       :     List[str]        =		torch.tensor(
         pretrained_model_params['predictions_output']['output_bias']							)
     __lowerCamelCase       :     List[Any]        =		torch.tensor(pretrained_model_params['predictions_output']['output_bias']							)

     # Seq Relationship Layers
     __lowerCamelCase       :     str        =		torch.tensor(
         pretrained_model_params['classification']['output_kernel']							)
     __lowerCamelCase       :     Dict        =		torch.tensor(
         pretrained_model_params['classification']['output_bias']							)

     # Load State Dict
     fnet_pretraining_model.load_state_dict(UpperCAmelCase_							)

     # Save PreTrained
     print(F'Saving pretrained model to {save_path}'							)
     fnet_pretraining_model.save_pretrained(UpperCAmelCase_							)


if __name__ == "__main__":
      A__		: int												=  argparse.ArgumentParser()
      # Required parameters
      parser.add_argument(
          """--flax_checkpoint_path""", default=None, type=str, required=True, help="""Path to the TensorFlow checkpoint path."""
      )
      parser.add_argument(
          """--fnet_config_file""",
          default=None,
          type=str,
          required=True,
          help=(
              """The config json file corresponding to the pre-trained FNet model. \n"""
              """This specifies the model architecture."""
          ),
      )
      parser.add_argument("""--save_path""", default=None, type=str, required=True, help="""Path to the output model.""")
      A__		: Optional[int]												=  parser.parse_args()
      convert_flax_checkpoint_to_pytorch(args.flax_checkpoint_path, args.fnet_config_file, args.save_path)










'''simple docstring'''



import math
from itertools import permutations



def       UpperCAmelCase__ (     UpperCAmelCase_   :    int							)					->		bool:

     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(UpperCAmelCase_							) + 1							)				,   6							):
          if number % i == 0 or number % (i + 2) == 0:
               return False
     return True



def       UpperCAmelCase__ (     UpperCAmelCase_   :    int				,   UpperCAmelCase_   :    list							)					->		bool:
     __lowerCamelCase    ,	__lowerCamelCase       :     str        =		0, len(UpperCAmelCase_							) - 1
     while left <= right:
          __lowerCamelCase       :     Optional[Any]        =		(left + right) // 2
          if prime_list[middle] == target:
               return True
          elif prime_list[middle] < target:
               __lowerCamelCase       :     Union[str, Any]        =		middle + 1
          else:
               __lowerCamelCase       :     Union[str, Any]        =		middle - 1

     return False



def       UpperCAmelCase__ (     )					->		List[str]:
     __lowerCamelCase       :     Tuple        =		[n for n in range(10_01				,   1_00_00				,   2							) if is_prime(UpperCAmelCase_							)]
     __lowerCamelCase       :     Any        =		[]

     for number in prime_list:
          __lowerCamelCase       :     Optional[int]        =		[]

          for prime_member in permutations(list(str(UpperCAmelCase_							)							)							):
               __lowerCamelCase       :     int        =		int(''.join(UpperCAmelCase_							)							)

               if prime % 2 == 0:
                    continue

               if search(UpperCAmelCase_				,   UpperCAmelCase_							):
                    tmp_numbers.append(UpperCAmelCase_							)

          tmp_numbers.sort()
          if len(UpperCAmelCase_							) >= 3:
               candidates.append(UpperCAmelCase_							)

     __lowerCamelCase       :     int        =		[]
     for candidate in candidates:
          __lowerCamelCase       :     Union[str, Any]        =		len(UpperCAmelCase_							)
          __lowerCamelCase       :     Optional[Any]        =		False

          for i in range(UpperCAmelCase_							):
               for j in range(i + 1				,   UpperCAmelCase_							):
                    for k in range(j + 1				,   UpperCAmelCase_							):
                         if (
                             abs(candidate[i] - candidate[j]							)
                             == abs(candidate[j] - candidate[k]							)
                             and len({candidate[i], candidate[j], candidate[k]}							) == 3
                         ):
                              passed.append(
                                  sorted([candidate[i], candidate[j], candidate[k]]							)							)
                              __lowerCamelCase       :     List[str]        =		True

                         if found:
                              break
                    if found:
                         break
               if found:
                    break

     __lowerCamelCase       :     List[Any]        =		set()
     for seq in passed:
          answer.add(''.join([str(UpperCAmelCase_							) for i in seq]							)							)

     return max(int(UpperCAmelCase_							) for x in answer							)


if __name__ == "__main__":
      print(solution())






