




import copy
import os
from typing import Dict, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...utils import add_start_docstrings, logging
from ..auto import AutoConfig


_lowerCAmelCase     :			Optional[int]    =logging.get_logger(__name__)


_lowerCAmelCase     :			List[Any]    ={
    """suno/bark-small""": """https://huggingface.co/suno/bark-small/resolve/main/config.json""",
    """suno/bark""": """https://huggingface.co/suno/bark/resolve/main/config.json""",
}

_lowerCAmelCase     :			str    ="""
    This is the configuration class to store the configuration of a [`{model}`]. It is used to instantiate the model
    according to the specified arguments, defining the model architecture. Instantiating a configuration with the
    defaults will yield a similar configuration to that of the Bark [suno/bark](https://huggingface.co/suno/bark)
    architecture.

    Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
    documentation from [`PretrainedConfig`] for more information.

    Args:
        block_size (`int`, *optional*, defaults to 1024):
            The maximum sequence length that this model might ever be used with. Typically set this to something large
            just in case (e.g., 512 or 1024 or 2048).
        input_vocab_size (`int`, *optional*, defaults to 10_048):
            Vocabulary size of a Bark sub-model. Defines the number of different tokens that can be represented by the
            `inputs_ids` passed when calling [`{model}`]. Defaults to 10_048 but should be carefully thought with
            regards to the chosen sub-model.
        output_vocab_size (`int`, *optional*, defaults to 10_048):
            Output vocabulary size of a Bark sub-model. Defines the number of different tokens that can be represented
            by the: `output_ids` when passing forward a [`{model}`]. Defaults to 10_048 but should be carefully thought
            with regards to the chosen sub-model.
        num_layers (`int`, *optional*, defaults to 12):
            Number of hidden layers in the given sub-model.
        num_heads (`int`, *optional*, defaults to 12):
            Number of attention heads for each attention layer in the Transformer architecture.
        hidden_size (`int`, *optional*, defaults to 768):
            Dimensionality of the \"intermediate\" (often named feed-forward) layer in the architecture.
        dropout (`float`, *optional*, defaults to 0.0):
            The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
        bias (`bool`, *optional*, defaults to `True`):
            Whether or not to use bias in the linear layers and layer norm layers.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        use_cache (`bool`, *optional*, defaults to `True`):
            Whether or not the model should return the last key/values attentions (not used by all models).
"""

class __UpperCamelCase    (							_a		):






					'''simple docstring'''



					__magic_name__     			=      "bark_module"
					__magic_name__     			=      ["past_key_values"]

					__magic_name__     			=      {
					    "num_attention_heads": "num_heads",
					    "num_hidden_layers": "num_layers",
					    "vocab_size": "input_vocab_size",
					    "window_size": "block_size",
					}





					def __init__(							self							,			lowerCamelCase__=1_0_2_4							,			lowerCamelCase__=1_0_0_4_8							,			lowerCamelCase__=1_0_0_4_8							,			lowerCamelCase__=1_2							,			lowerCamelCase__=1_2							,			lowerCamelCase__=7_6_8							,			lowerCamelCase__=0.0							,			lowerCamelCase__=True							,			lowerCamelCase__=0.02							,			lowerCamelCase__=True							,			**lowerCamelCase__							,			):
						UpperCAmelCase__:  Union[str, Any]		       =   block_size
						UpperCAmelCase__:  Tuple		       =   input_vocab_size
						UpperCAmelCase__:  List[Any]		       =   output_vocab_size
						UpperCAmelCase__:  Union[str, Any]		       =   num_layers
						UpperCAmelCase__:  Any		       =   num_heads
						UpperCAmelCase__:  List[Any]		       =   hidden_size
						UpperCAmelCase__:  List[str]		       =   dropout
						UpperCAmelCase__:  Tuple		       =   bias
						UpperCAmelCase__:  List[str]		       =   use_cache
						UpperCAmelCase__:  Optional[Any]		       =   initializer_range

						super().__init__(**lowerCamelCase__	)





					@classmethod
					def       _UpperCAmelCase						(							cls							,			lowerCamelCase__							,			lowerCamelCase__ = None							,			lowerCamelCase__ = False							,			lowerCamelCase__ = False							,			lowerCamelCase__ = None							,			lowerCamelCase__ = "main"							,			**lowerCamelCase__							,			):
						UpperCAmelCase__:  List[str]		       =   cache_dir
						UpperCAmelCase__:  str		       =   force_download
						UpperCAmelCase__:  List[str]		       =   local_files_only
						UpperCAmelCase__:  List[str]		       =   revision

						cls._set_token_in_kwargs(lowerCamelCase__							,			lowerCamelCase__	)

						UpperCAmelCase__:  Tuple		       =   cls.get_config_dict(lowerCamelCase__							,			**lowerCamelCase__	)

						# get the config dict if we are loading from Bark
						if config_dict.get("model_type"	) == "bark":
							UpperCAmelCase__:  Dict		       =   config_dict[F"{cls.model_type}_config"]

						if "model_type" in config_dict and hasattr(cls							,			"model_type"	) and config_dict["model_type"] != cls.model_type:
							logger.warning(
							    F"You are using a model of type {config_dict['model_type']} to instantiate a model of type "
							    F"{cls.model_type}. This is not supported for all configurations of models and can yield errors."	)

						return cls.from_dict(lowerCamelCase__							,			**lowerCamelCase__	)

@add_start_docstrings(
    BARK_SUBMODELCONFIG_START_DOCSTRING.format(config="BarkSemanticConfig"				,model="BarkSemanticModel"		)				,"\n    Example:\n\n    ```python\n    >>> from transformers import BarkSemanticConfig, BarkSemanticModel\n\n    >>> # Initializing a Bark sub-module style configuration\n    >>> configuration = BarkSemanticConfig()\n\n    >>> # Initializing a model (with random weights) from the suno/bark style configuration\n    >>> model = BarkSemanticModel(configuration)\n\n    >>> # Accessing the model configuration\n    >>> configuration = model.config\n    ```"				,)
class __UpperCamelCase    (							_a		):






					'''simple docstring'''



					__magic_name__     			=      "semantic"

@add_start_docstrings(
    BARK_SUBMODELCONFIG_START_DOCSTRING.format(config="BarkCoarseConfig"				,model="BarkCoarseModel"		)				,"\n    Example:\n\n    ```python\n    >>> from transformers import BarkCoarseConfig, BarkCoarseModel\n\n    >>> # Initializing a Bark sub-module style configuration\n    >>> configuration = BarkCoarseConfig()\n\n    >>> # Initializing a model (with random weights) from the suno/bark style configuration\n    >>> model = BarkCoarseModel(configuration)\n\n    >>> # Accessing the model configuration\n    >>> configuration = model.config\n    ```"				,)
class __UpperCamelCase    (							_a		):






					'''simple docstring'''



					__magic_name__     			=      "coarse_acoustics"

@add_start_docstrings(
    BARK_SUBMODELCONFIG_START_DOCSTRING.format(config="BarkFineConfig"				,model="BarkFineModel"		)				,"\n        n_codes_total (`int`, *optional*, defaults to 8):\n            The total number of audio codebooks predicted. Used in the fine acoustics sub-model.\n        n_codes_given (`int`, *optional*, defaults to 1):\n            The number of audio codebooks predicted in the coarse acoustics sub-model. Used in the acoustics\n            sub-models.\n    Example:\n\n    ```python\n    >>> from transformers import BarkFineConfig, BarkFineModel\n\n    >>> # Initializing a Bark sub-module style configuration\n    >>> configuration = BarkFineConfig()\n\n    >>> # Initializing a model (with random weights) from the suno/bark style configuration\n    >>> model = BarkFineModel(configuration)\n\n    >>> # Accessing the model configuration\n    >>> configuration = model.config\n    ```"				,)
class __UpperCamelCase    (							_a		):






					'''simple docstring'''



					__magic_name__     			=      "fine_acoustics"





					def __init__(							self							,			lowerCamelCase__=True							,			lowerCamelCase__=8							,			lowerCamelCase__=1							,			**lowerCamelCase__	):
						UpperCAmelCase__:  List[str]		       =   n_codes_total
						UpperCAmelCase__:  Dict		       =   n_codes_given

						super().__init__(tie_word_embeddings=lowerCamelCase__							,			**lowerCamelCase__	)

class __UpperCamelCase    (							_a		):






					'''simple docstring'''



					__magic_name__     			=      "bark"
					__magic_name__     			=      True





					def __init__(							self							,			lowerCamelCase__ = None							,			lowerCamelCase__ = None							,			lowerCamelCase__ = None							,			lowerCamelCase__ = None							,			lowerCamelCase__=0.02							,			**lowerCamelCase__							,			):
						if semantic_config is None:
							UpperCAmelCase__:  Union[str, Any]		       =   {}
							logger.info("semantic_config is None. initializing the semantic model with default values."	)

						if coarse_acoustics_config is None:
							UpperCAmelCase__:  str		       =   {}
							logger.info("coarse_acoustics_config is None. initializing the coarse model with default values."	)

						if fine_acoustics_config is None:
							UpperCAmelCase__:  Tuple		       =   {}
							logger.info("fine_acoustics_config is None. initializing the fine model with default values."	)

						if codec_config is None:
							UpperCAmelCase__:  int		       =   {}
							logger.info("codec_config is None. initializing the codec model with default values."	)

						UpperCAmelCase__:  Optional[Any]		       =   BarkSemanticConfig(**lowerCamelCase__	)
						UpperCAmelCase__:  int		       =   BarkCoarseConfig(**lowerCamelCase__	)
						UpperCAmelCase__:  int		       =   BarkFineConfig(**lowerCamelCase__	)
						UpperCAmelCase__:  Union[str, Any]		       =   AutoConfig.for_model(**lowerCamelCase__	)

						UpperCAmelCase__:  List[Any]		       =   initializer_range

						super().__init__(**lowerCamelCase__	)





					@classmethod
					def       _UpperCAmelCase						(							cls							,			lowerCamelCase__							,			lowerCamelCase__							,			lowerCamelCase__							,			lowerCamelCase__							,			**lowerCamelCase__							,			):
						return cls(
						    semantic_config=semantic_config.to_dict()							,			coarse_acoustics_config=coarse_acoustics_config.to_dict()							,			fine_acoustics_config=fine_acoustics_config.to_dict()							,			codec_config=codec_config.to_dict()							,			**lowerCamelCase__							,			)





					def       _UpperCAmelCase						(							self	):
						UpperCAmelCase__:  List[str]		       =   copy.deepcopy(self.__dict__	)

						UpperCAmelCase__:  List[str]		       =   self.semantic_config.to_dict()
						UpperCAmelCase__:  Optional[Any]		       =   self.coarse_acoustics_config.to_dict()
						UpperCAmelCase__:  Any		       =   self.fine_acoustics_config.to_dict()
						UpperCAmelCase__:  List[str]		       =   self.codec_config.to_dict()

						UpperCAmelCase__:  Union[str, Any]		       =   self.__class__.model_type
						return output


from __future__ import annotations

from collections import Counter



def  _A  (			SCREAMING_SNAKE_CASE			):
	UpperCAmelCase__:  Optional[Any]		       =   [True] * n
	UpperCAmelCase__:  Any		       =   False
	UpperCAmelCase__:  Tuple		       =   False
	UpperCAmelCase__:  Optional[Any]		       =   True

	for i in range(3  ,int(n**0.5 + 1			)  ,2			):
		UpperCAmelCase__:  Any		       =   i * 2
		while index < n:
			UpperCAmelCase__:  Optional[int]		       =   False
			UpperCAmelCase__:  Tuple		       =   index + i

	UpperCAmelCase__:  int		       =   [2]

	for i in range(3  ,SCREAMING_SNAKE_CASE  ,2			):
		if is_prime[i]:
			primes.append(SCREAMING_SNAKE_CASE			)

	return primes



def  _A  (			SCREAMING_SNAKE_CASE			):
	UpperCAmelCase__:  List[Any]		       =   str(SCREAMING_SNAKE_CASE			)
	UpperCAmelCase__:  Tuple		       =   []
	UpperCAmelCase__:  Optional[int]		       =   ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]

	for duplicate in Counter(SCREAMING_SNAKE_CASE			) - Counter(set(SCREAMING_SNAKE_CASE			)			):
		UpperCAmelCase__:  Optional[Any]		       =   [int(number_str.replace(SCREAMING_SNAKE_CASE  ,SCREAMING_SNAKE_CASE			)			) for digit in digits]
		replacements.append(SCREAMING_SNAKE_CASE			)

	return replacements



def  _A  (			SCREAMING_SNAKE_CASE = 8			):
	UpperCAmelCase__:  Union[str, Any]		       =   set()

	# Filter primes with less than 3 replaceable digits
	UpperCAmelCase__:  Optional[Any]		       =   {
	    x for x in set(prime_sieve(1_0_0_0_0_0_0			)			) if len(str(SCREAMING_SNAKE_CASE			)			) - len(set(str(SCREAMING_SNAKE_CASE			)			)			) >= 3
	}

	for prime in primes:
		if prime in numbers_checked:
			continue

		UpperCAmelCase__:  Optional[int]		       =   digit_replacements(SCREAMING_SNAKE_CASE			)

		for family in replacements:
			numbers_checked.update(SCREAMING_SNAKE_CASE			)
			UpperCAmelCase__:  Dict		       =   primes.intersection(SCREAMING_SNAKE_CASE			)

			if len(SCREAMING_SNAKE_CASE			) != family_length:
				continue

			return min(SCREAMING_SNAKE_CASE			)

	return -1


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