




'''simple docstring'''






import functools
import operator

from ...configuration_utils import PretrainedConfig
from ...utils import logging


A_			      =		logging.get_logger(__name__)

A_			      =		{
    "microsoft/unispeech-sat-base-100h-libri-ft": (
        "https://huggingface.co/microsoft/unispeech-sat-base-100h-libri-ft/resolve/main/config.json"
    ),
    # See all UniSpeechSat models at https://huggingface.co/models?filter=unispeech_sat
}






class        lowercase_      (						lowerCAmelCase_							):
     A_											=			"unispeech-sat"





     def __init__(     self     :					Dict     ,							__lowerCamelCase     :					List[Any]=32     ,							__lowerCamelCase     :					Tuple=768     ,							__lowerCamelCase     :					List[str]=12     ,							__lowerCamelCase     :					List[Any]=12     ,							__lowerCamelCase     :					Union[str, Any]=3072     ,							__lowerCamelCase     :					Optional[int]="gelu"     ,							__lowerCamelCase     :					List[Any]=0.1     ,							__lowerCamelCase     :					Union[str, Any]=0.1     ,							__lowerCamelCase     :					Any=0.1     ,							__lowerCamelCase     :					Optional[Any]=0.0     ,							__lowerCamelCase     :					Dict=0.0     ,							__lowerCamelCase     :					Optional[Any]=0.1     ,							__lowerCamelCase     :					Union[str, Any]=0.1     ,							__lowerCamelCase     :					List[Any]=0.0_2     ,							__lowerCamelCase     :					Optional[Any]=1E-5     ,							__lowerCamelCase     :					Dict="group"     ,							__lowerCamelCase     :					Tuple="gelu"     ,							__lowerCamelCase     :					Optional[Any]=(512, 512, 512, 512, 512, 512, 512)     ,							__lowerCamelCase     :					List[Any]=(5, 2, 2, 2, 2, 2, 2)     ,							__lowerCamelCase     :					Tuple=(10, 3, 3, 3, 3, 2, 2)     ,							__lowerCamelCase     :					Any=False     ,							__lowerCamelCase     :					Union[str, Any]=128     ,							__lowerCamelCase     :					Any=16     ,							__lowerCamelCase     :					Optional[Any]=False     ,							__lowerCamelCase     :					Tuple=True     ,							__lowerCamelCase     :					Tuple=0.0_5     ,							__lowerCamelCase     :					Optional[Any]=10     ,							__lowerCamelCase     :					List[str]=2     ,							__lowerCamelCase     :					Optional[Any]=0.0     ,							__lowerCamelCase     :					List[Any]=10     ,							__lowerCamelCase     :					List[str]=0     ,							__lowerCamelCase     :					List[Any]=320     ,							__lowerCamelCase     :					Union[str, Any]=2     ,							__lowerCamelCase     :					Dict=0.1     ,							__lowerCamelCase     :					List[Any]=100     ,							__lowerCamelCase     :					List[Any]=256     ,							__lowerCamelCase     :					str=256     ,							__lowerCamelCase     :					List[Any]=0.1     ,							__lowerCamelCase     :					str="mean"     ,							__lowerCamelCase     :					Dict=False     ,							__lowerCamelCase     :					Optional[Any]=False     ,							__lowerCamelCase     :					int=256     ,							__lowerCamelCase     :					Optional[Any]=(512, 512, 512, 512, 1500)     ,							__lowerCamelCase     :					Union[str, Any]=(5, 3, 3, 1, 1)     ,							__lowerCamelCase     :					List[Any]=(1, 2, 3, 1, 1)     ,							__lowerCamelCase     :					Dict=512     ,							__lowerCamelCase     :					List[Any]=0     ,							__lowerCamelCase     :					Optional[int]=1     ,							__lowerCamelCase     :					List[Any]=2     ,							__lowerCamelCase     :					Any=504     ,							**__lowerCamelCase     :					List[Any]     ,							):
           super().__init__(**__lowerCamelCase     ,							pad_token_id=__lowerCamelCase     ,							bos_token_id=__lowerCamelCase     ,							eos_token_id=__lowerCamelCase			)
           snake_case__       :   Tuple	      =    hidden_size
           snake_case__       :   Any	      =    feat_extract_norm
           snake_case__       :   Any	      =    feat_extract_activation
           snake_case__       :   Any	      =    list(__lowerCamelCase			)
           snake_case__       :   str	      =    list(__lowerCamelCase			)
           snake_case__       :   Union[str, Any]	      =    list(__lowerCamelCase			)
           snake_case__       :   Optional[Any]	      =    conv_bias
           snake_case__       :   List[str]	      =    num_conv_pos_embeddings
           snake_case__       :   List[Any]	      =    num_conv_pos_embedding_groups
           snake_case__       :   Dict	      =    len(self.conv_dim			)
           snake_case__       :   Any	      =    num_hidden_layers
           snake_case__       :   List[str]	      =    intermediate_size
           snake_case__       :   List[str]	      =    hidden_act
           snake_case__       :   Any	      =    num_attention_heads
           snake_case__       :   List[str]	      =    hidden_dropout
           snake_case__       :   int	      =    attention_dropout
           snake_case__       :   int	      =    activation_dropout
           snake_case__       :   Dict	      =    feat_proj_dropout
           snake_case__       :   Any	      =    final_dropout
           snake_case__       :   Any	      =    layerdrop
           snake_case__       :   Dict	      =    layer_norm_eps
           snake_case__       :   Optional[int]	      =    initializer_range
           snake_case__       :   int	      =    vocab_size
           snake_case__       :   Dict	      =    num_clusters
           snake_case__       :   str	      =    do_stable_layer_norm
           snake_case__       :   Union[str, Any]	      =    use_weighted_layer_sum

           if (
               (len(self.conv_stride			) != self.num_feat_extract_layers)
               or (len(self.conv_kernel			) != self.num_feat_extract_layers)
               or (len(self.conv_dim			) != self.num_feat_extract_layers)
           ):
                 raise ValueError(
                     'Configuration for convolutional layers is incorrect. It is required that `len(config.conv_dim)` =='
                     ' `len(config.conv_stride)` == `len(config.conv_kernel)`, but is `len(config.conv_dim) ='
                     F" {len(self.conv_dim			)}`, `len(config.conv_stride) = {len(self.conv_stride			)}`,"
                     F" `len(config.conv_kernel) = {len(self.conv_kernel			)}`."			)

           # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
           snake_case__       :   List[str]	      =    apply_spec_augment
           snake_case__       :   Optional[int]	      =    mask_time_prob
           snake_case__       :   int	      =    mask_time_length
           snake_case__       :   Dict	      =    mask_time_min_masks
           snake_case__       :   Optional[Any]	      =    mask_feature_prob
           snake_case__       :   Union[str, Any]	      =    mask_feature_length
           snake_case__       :   Any	      =    mask_feature_min_masks

           # parameters for pretraining with codevector quantized representations
           snake_case__       :   Dict	      =    num_codevectors_per_group
           snake_case__       :   Optional[Any]	      =    num_codevector_groups
           snake_case__       :   Dict	      =    contrastive_logits_temperature
           snake_case__       :   Tuple	      =    feat_quantizer_dropout
           snake_case__       :   Dict	      =    num_negatives
           snake_case__       :   Union[str, Any]	      =    codevector_dim
           snake_case__       :   List[Any]	      =    proj_codevector_dim
           snake_case__       :   int	      =    diversity_loss_weight

           # ctc loss
           snake_case__       :   Optional[Any]	      =    ctc_loss_reduction
           snake_case__       :   List[Any]	      =    ctc_zero_infinity

           # SequenceClassification-specific parameter. Feel free to ignore for other classes.
           snake_case__       :   Tuple	      =    classifier_proj_size

           # XVector-specific parameters. Feel free to ignore for other classes.
           snake_case__       :   Optional[Any]	      =    list(__lowerCamelCase			)
           snake_case__       :   Tuple	      =    list(__lowerCamelCase			)
           snake_case__       :   str	      =    list(__lowerCamelCase			)
           snake_case__       :   Optional[Any]	      =    xvector_output_dim





     @property
     def 			_lowerCAmelCase      (     self     :					List[str]			):
           return functools.reduce(operator.mul     ,							self.conv_stride     ,							1			)






'''simple docstring'''






# This code is adapted from OpenAI's release
# https://github.com/openai/human-eval/blob/master/human_eval/execution.py

import contextlib
import faulthandler
import io
import multiprocessing
import os
import platform
import signal
import tempfile






def 		UpperCamelCase__      (		__SCREAMING_SNAKE_CASE				,      __SCREAMING_SNAKE_CASE				,      __SCREAMING_SNAKE_CASE				,      __SCREAMING_SNAKE_CASE		)    ->   Dict:
      snake_case__       :   int	      =    multiprocessing.Manager()
      snake_case__       :   Any	      =    manager.list()

      snake_case__       :   List[str]	      =    multiprocessing.Process(target=__SCREAMING_SNAKE_CASE				,      args=(check_program, result, timeout)		)
      p.start()
      p.join(timeout=timeout + 1		)
      if p.is_alive():
            p.kill()

      if not result:
            result.append('timed out'		)

      return {
          "task_id": task_id,
          "passed": result[0] == "passed",
          "result": result[0],
          "completion_id": completion_id,
      }






def 		UpperCamelCase__      (		__SCREAMING_SNAKE_CASE				,      __SCREAMING_SNAKE_CASE				,      __SCREAMING_SNAKE_CASE		)    ->   Tuple:
      with create_tempdir():
            # These system calls are needed when cleaning up tempdir.
            import os
            import shutil

            snake_case__       :   List[Any]	      =    shutil.rmtree
            snake_case__       :   Tuple	      =    os.rmdir
            snake_case__       :   Any	      =    os.chdir

            # Disable functionalities that can make destructive changes to the test.
            reliability_guard()

            # Run program.
            try:
                  snake_case__       :   Union[str, Any]	      =    {}
                  with swallow_io():
                        with time_limit(__SCREAMING_SNAKE_CASE		):
                              exec(__SCREAMING_SNAKE_CASE				,      __SCREAMING_SNAKE_CASE		)
                  result.append('passed'		)
            except TimeoutException:
                  result.append('timed out'		)
            except BaseException as e:
                  result.append(f"failed: {e}"		)

            # Needed for cleaning up.
            snake_case__       :   List[Any]	      =    rmtree
            snake_case__       :   Optional[int]	      =    rmdir
            snake_case__       :   Dict	      =    chdir






@contextlib.contextmanager
def 		UpperCamelCase__      (		__SCREAMING_SNAKE_CASE		)    ->   List[str]:
      def signal_handler(__SCREAMING_SNAKE_CASE				,      __SCREAMING_SNAKE_CASE		):
            raise TimeoutException('Timed out!'		)

      signal.setitimer(signal.ITIMER_REAL				,      __SCREAMING_SNAKE_CASE		)
      signal.signal(signal.SIGALRM				,      __SCREAMING_SNAKE_CASE		)
      try:
            yield
      finally:
            signal.setitimer(signal.ITIMER_REAL				,      0		)






@contextlib.contextmanager
def 		UpperCamelCase__      (		)    ->   List[str]:
      snake_case__       :   Dict	      =    WriteOnlyStringIO()
      with contextlib.redirect_stdout(__SCREAMING_SNAKE_CASE		):
            with contextlib.redirect_stderr(__SCREAMING_SNAKE_CASE		):
                  with redirect_stdin(__SCREAMING_SNAKE_CASE		):
                        yield






@contextlib.contextmanager
def 		UpperCamelCase__      (		)    ->   Optional[int]:
      with tempfile.TemporaryDirectory() as dirname:
            with chdir(__SCREAMING_SNAKE_CASE		):
                  yield dirname






class        lowercase_      (						lowerCAmelCase_							):
     pass






class        lowercase_      (						io.StringIO							):





     def 			_lowerCAmelCase      (     self     :					Optional[Any]     ,							*__lowerCamelCase     :					int     ,							**__lowerCamelCase     :					Optional[int]			):
           raise OSError





     def 			_lowerCAmelCase      (     self     :					int     ,							*__lowerCamelCase     :					List[Any]     ,							**__lowerCamelCase     :					Tuple			):
           raise OSError





     def 			_lowerCAmelCase      (     self     :					Any     ,							*__lowerCamelCase     :					int     ,							**__lowerCamelCase     :					Union[str, Any]			):
           raise OSError





     def 			_lowerCAmelCase      (     self     :					Tuple     ,							*__lowerCamelCase     :					List[str]     ,							**__lowerCamelCase     :					Optional[Any]			):
           return False






class        lowercase_      (						contextlib._RedirectStream							):  # type: ignore
     A_											=			"stdin"






@contextlib.contextmanager
def 		UpperCamelCase__      (		__SCREAMING_SNAKE_CASE		)    ->   List[str]:
      if root == ".":
            yield
            return
      snake_case__       :   str	      =    os.getcwd()
      os.chdir(__SCREAMING_SNAKE_CASE		)
      try:
            yield
      except BaseException as exc:
            raise exc
      finally:
            os.chdir(__SCREAMING_SNAKE_CASE		)






def 		UpperCamelCase__      (		__SCREAMING_SNAKE_CASE=None		)    ->   Any:

      if maximum_memory_bytes is not None:
            import resource

            resource.setrlimit(resource.RLIMIT_AS				,      (maximum_memory_bytes, maximum_memory_bytes)		)
            resource.setrlimit(resource.RLIMIT_DATA				,      (maximum_memory_bytes, maximum_memory_bytes)		)
            if not platform.uname().system == "Darwin":
                  resource.setrlimit(resource.RLIMIT_STACK				,      (maximum_memory_bytes, maximum_memory_bytes)		)

      faulthandler.disable()

      import builtins

      snake_case__       :   List[Any]	      =    None
      snake_case__       :   List[str]	      =    None

      import os

      snake_case__       :   List[Any]	      =    '1'

      snake_case__       :   Union[str, Any]	      =    None
      snake_case__       :   Tuple	      =    None
      snake_case__       :   Dict	      =    None
      snake_case__       :   Tuple	      =    None
      snake_case__       :   List[str]	      =    None
      snake_case__       :   Any	      =    None
      snake_case__       :   Optional[Any]	      =    None
      snake_case__       :   Union[str, Any]	      =    None
      snake_case__       :   int	      =    None
      snake_case__       :   Optional[int]	      =    None
      snake_case__       :   Union[str, Any]	      =    None
      snake_case__       :   List[Any]	      =    None
      snake_case__       :   Optional[int]	      =    None
      snake_case__       :   Union[str, Any]	      =    None
      snake_case__       :   Tuple	      =    None
      snake_case__       :   int	      =    None
      snake_case__       :   Optional[Any]	      =    None
      snake_case__       :   Optional[int]	      =    None
      snake_case__       :   List[str]	      =    None
      snake_case__       :   List[str]	      =    None
      snake_case__       :   List[str]	      =    None
      snake_case__       :   Dict	      =    None
      snake_case__       :   Optional[Any]	      =    None
      snake_case__       :   List[Any]	      =    None
      snake_case__       :   Tuple	      =    None
      snake_case__       :   Optional[int]	      =    None
      snake_case__       :   int	      =    None

      import shutil

      snake_case__       :   List[str]	      =    None
      snake_case__       :   List[Any]	      =    None
      snake_case__       :   List[Any]	      =    None

      import subprocess

      snake_case__       :   int	      =    None  # type: ignore

      snake_case__       :   Dict	      =    None

      import sys

      snake_case__       :   Tuple	      =    None
      snake_case__       :   Tuple	      =    None
      snake_case__       :   List[str]	      =    None
      snake_case__       :   Optional[int]	      =    None
      snake_case__       :   List[Any]	      =    None
