






"""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       _lowerCAmelCase       (      lowerCAmelCase	,      lowerCAmelCase	,      lowerCAmelCase	,      lowerCAmelCase		):







       '''simple docstring'''
       UpperCAmelCase	    =			multiprocessing.Manager()
       UpperCAmelCase	    =			manager.list()

       UpperCAmelCase	    =			multiprocessing.Process(target=a__	,      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       _lowerCAmelCase       (      lowerCAmelCase	,      lowerCAmelCase	,      lowerCAmelCase		):







       '''simple docstring'''

       with create_tempdir():
              # These system calls are needed when cleaning up tempdir.
              import os
              import shutil

              UpperCAmelCase	    =			shutil.rmtree
              UpperCAmelCase	    =			os.rmdir
              UpperCAmelCase	    =			os.chdir

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

              # Run program.
              try:
                     UpperCAmelCase	    =			{}
                     with swallow_io():
                            with time_limit(a__		):
                                   exec(a__	,      a__		)
                     result.append("""passed"""		)
              except TimeoutException:
                     result.append("""timed out"""		)
              except BaseException as e:
                     result.append(F'''failed: {e}'''		)

              # Needed for cleaning up.
              UpperCAmelCase	    =			rmtree
              UpperCAmelCase	    =			rmdir
              UpperCAmelCase	    =			chdir






@contextlib.contextmanager
def       _lowerCAmelCase       (      lowerCAmelCase		):







       '''simple docstring'''

       def signal_handler(lowerCAmelCase	,      lowerCAmelCase		):
              raise TimeoutException("""Timed out!"""		)

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






@contextlib.contextmanager
def       _lowerCAmelCase       (      ):







       '''simple docstring'''
       UpperCAmelCase	    =			WriteOnlyStringIO()
       with contextlib.redirect_stdout(a__		):
              with contextlib.redirect_stderr(a__		):
                     with redirect_stdin(a__		):
                            yield






@contextlib.contextmanager
def       _lowerCAmelCase       (      ):







       '''simple docstring'''

       with tempfile.TemporaryDirectory() as dirname:
              with chdir(a__		):
                     yield dirname





class   UpperCamelCase_ (       a_  ):

  '''simple docstring'''





  pass





class   UpperCamelCase_ (       io.StringIO  ):

  '''simple docstring'''





  def 		UpperCamelCase_				(      self ,		*snake_case__ ,		**snake_case__				)			->			Any:



         """simple docstring"""





         raise OSError



  def 		UpperCamelCase_				(      self ,		*snake_case__ ,		**snake_case__				)			->			Optional[Any]:



         """simple docstring"""





         raise OSError



  def 		UpperCamelCase_				(      self ,		*snake_case__ ,		**snake_case__				)			->			Optional[int]:



         """simple docstring"""





         raise OSError



  def 		UpperCamelCase_				(      self ,		*snake_case__ ,		**snake_case__				)			->			List[str]:



         """simple docstring"""





         return False





class   UpperCamelCase_ (       contextlib._RedirectStream  ):  # type: ignore

  '''simple docstring'''





  _A       :					Optional[Any]				=	'stdin'






@contextlib.contextmanager
def       _lowerCAmelCase       (      lowerCAmelCase		):







       '''simple docstring'''

       if root == ".":
              yield
              return
       UpperCAmelCase	    =			os.getcwd()
       os.chdir(a__		)
       try:
              yield
       except BaseException as exc:
              raise exc
       finally:
              os.chdir(a__		)






def       _lowerCAmelCase       (      lowerCAmelCase=None		):







       '''simple docstring'''

       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

       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None

       import os

       UpperCAmelCase	    =			"""1"""

       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None

       import shutil

       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None

       import subprocess

       UpperCAmelCase	    =			None  # type: ignore

       UpperCAmelCase	    =			None

       import sys

       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None
       UpperCAmelCase	    =			None








"""simple docstring"""







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


lowerCAmelCase_	:    Any            =      logging.get_logger(__name__)

lowerCAmelCase_	:    Any            =      {
    '''google/canine-s''': '''https://huggingface.co/google/canine-s/resolve/main/config.json''',
    # See all CANINE models at https://huggingface.co/models?filter=canine
}





class   UpperCamelCase_ (       a_  ):
  _A       :					Tuple				=	'canine'



  def __init__(      self ,		snake_case__=7_68 ,		snake_case__=12 ,		snake_case__=12 ,		snake_case__=30_72 ,		snake_case__="gelu" ,		snake_case__=0.1 ,		snake_case__=0.1 ,		snake_case__=1_63_84 ,		snake_case__=16 ,		snake_case__=0.02 ,		snake_case__=1e-12 ,		snake_case__=0 ,		snake_case__=0xE_0_0_0 ,		snake_case__=0xE_0_0_1 ,		snake_case__=4 ,		snake_case__=4 ,		snake_case__=8 ,		snake_case__=1_63_84 ,		snake_case__=1_28 ,		**snake_case__ ,		)			->			int:



         """simple docstring"""





         super().__init__(pad_token_id=snake_case__ ,		bos_token_id=snake_case__ ,		eos_token_id=snake_case__ ,		**snake_case__				)

         UpperCAmelCase	    =			max_position_embeddings
         UpperCAmelCase	    =			hidden_size
         UpperCAmelCase	    =			num_hidden_layers
         UpperCAmelCase	    =			num_attention_heads
         UpperCAmelCase	    =			intermediate_size
         UpperCAmelCase	    =			hidden_act
         UpperCAmelCase	    =			hidden_dropout_prob
         UpperCAmelCase	    =			attention_probs_dropout_prob
         UpperCAmelCase	    =			initializer_range
         UpperCAmelCase	    =			type_vocab_size
         UpperCAmelCase	    =			layer_norm_eps

         # Character config:
         UpperCAmelCase	    =			downsampling_rate
         UpperCAmelCase	    =			upsampling_kernel_size
         UpperCAmelCase	    =			num_hash_functions
         UpperCAmelCase	    =			num_hash_buckets
         UpperCAmelCase	    =			local_transformer_stride
