





'''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 	__a(SCREAMING_SNAKE_CASE_  :					List[str]		,       SCREAMING_SNAKE_CASE_  :					List[str]		,       SCREAMING_SNAKE_CASE_  :					Any		,       SCREAMING_SNAKE_CASE_  :					Optional[int]    ):



    '''simple docstring'''





    _lowerCAmelCase				=      multiprocessing.Manager()
    _lowerCAmelCase				=      manager.list()

    _lowerCAmelCase				=      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 	__a(SCREAMING_SNAKE_CASE_  :					Dict		,       SCREAMING_SNAKE_CASE_  :					Optional[Any]		,       SCREAMING_SNAKE_CASE_  :					Tuple    ):



    '''simple docstring'''





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

        _lowerCAmelCase				=      shutil.rmtree
        _lowerCAmelCase				=      os.rmdir
        _lowerCAmelCase				=      os.chdir

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

        # Run program.
        try:
            _lowerCAmelCase				=      {}
            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.
        _lowerCAmelCase				=      rmtree
        _lowerCAmelCase				=      rmdir
        _lowerCAmelCase				=      chdir


@contextlib.contextmanager
def 	__a(SCREAMING_SNAKE_CASE_  :					Optional[int]    ):



    '''simple docstring'''





    def signal_handler(SCREAMING_SNAKE_CASE_  :					List[str]		,       SCREAMING_SNAKE_CASE_  :					Union[str, Any]    ):
        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 	__a():



    '''simple docstring'''





    _lowerCAmelCase				=      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 	__a():



    '''simple docstring'''





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

class    lowerCAmelCase_		(		__magic_name__		):
 pass







class    lowerCAmelCase_		(		io.StringIO		):




 def 							_snake_case   (	self			,     *_lowerCAmelCase			,     **_lowerCAmelCase		)    ->							List[Any]:
     raise OSError




 def 							_snake_case   (	self			,     *_lowerCAmelCase			,     **_lowerCAmelCase		)    ->							List[Any]:
     raise OSError




 def 							_snake_case   (	self			,     *_lowerCAmelCase			,     **_lowerCAmelCase		)    ->							int:
     raise OSError





 def 							_snake_case   (	self			,     *_lowerCAmelCase			,     **_lowerCAmelCase		)    ->							List[str]:
     return False







class    lowerCAmelCase_		(		contextlib._RedirectStream		):  # type: ignore
 __lowerCamelCase						:							str         =					"stdin"







@contextlib.contextmanager
def 	__a(SCREAMING_SNAKE_CASE_  :					List[str]    ):



    '''simple docstring'''





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





def 	__a(SCREAMING_SNAKE_CASE_  :					str=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

    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None

    import os

    _lowerCAmelCase				=      "1"

    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None

    import shutil

    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None

    import subprocess

    _lowerCAmelCase				=      None  # type: ignore

    _lowerCAmelCase				=      None

    import sys

    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None
    _lowerCAmelCase				=      None









'''simple docstring'''


from ...configuration_utils import PretrainedConfig

class    lowerCAmelCase_		(		__magic_name__		):
 __lowerCamelCase						:							List[str]         =					"bert-generation"




 def __init__(	self			,     _lowerCAmelCase=50358			,     _lowerCAmelCase=1024			,     _lowerCAmelCase=24			,     _lowerCAmelCase=16			,     _lowerCAmelCase=4096			,     _lowerCAmelCase="gelu"			,     _lowerCAmelCase=0.1			,     _lowerCAmelCase=0.1			,     _lowerCAmelCase=512			,     _lowerCAmelCase=0.02			,     _lowerCAmelCase=1E-12			,     _lowerCAmelCase=0			,     _lowerCAmelCase=2			,     _lowerCAmelCase=1			,     _lowerCAmelCase="absolute"			,     _lowerCAmelCase=True			,     **_lowerCAmelCase			,     )    ->							Tuple:
     super().__init__(pad_token_id=_lowerCAmelCase			,     bos_token_id=_lowerCAmelCase			,     eos_token_id=_lowerCAmelCase			,     **_lowerCAmelCase		)

     _lowerCAmelCase				=      vocab_size
     _lowerCAmelCase				=      hidden_size
     _lowerCAmelCase				=      num_hidden_layers
     _lowerCAmelCase				=      num_attention_heads
     _lowerCAmelCase				=      hidden_act
     _lowerCAmelCase				=      intermediate_size
     _lowerCAmelCase				=      hidden_dropout_prob
     _lowerCAmelCase				=      attention_probs_dropout_prob
     _lowerCAmelCase				=      max_position_embeddings
     _lowerCAmelCase				=      initializer_range
     _lowerCAmelCase				=      layer_norm_eps
     _lowerCAmelCase				=      position_embedding_type
     _lowerCAmelCase				=      use_cache


