






# 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   __lowercase       (			snake_case,	snake_case,	snake_case,	snake_case			):







				"""simple docstring"""






				__magic_name__		:Any   =   multiprocessing.Manager()
				__magic_name__		:Tuple   =   manager.list()

				__magic_name__		:Dict   =   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   __lowercase       (			snake_case,	snake_case,	snake_case			):







				"""simple docstring"""






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

								__magic_name__		:Optional[int]   =   shutil.rmtree
								__magic_name__		:Dict   =   os.rmdir
								__magic_name__		:List[str]   =   os.chdir

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

								# Run program.
								try:
												__magic_name__		:Union[str, Any]   =   {}
												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.
								__magic_name__		:Optional[int]   =   rmtree
								__magic_name__		:Dict   =   rmdir
								__magic_name__		:int   =   chdir

@contextlib.contextmanager
def   __lowercase       (			snake_case			):







				"""simple docstring"""






				def signal_handler(snake_case,	snake_case			):
								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   __lowercase       (			):







				"""simple docstring"""






				__magic_name__		:str   =   WriteOnlyStringIO()
				with contextlib.redirect_stdout(a__			):
								with contextlib.redirect_stderr(a__			):
												with redirect_stdin(a__			):
																yield

@contextlib.contextmanager
def   __lowercase       (			):







				"""simple docstring"""






				with tempfile.TemporaryDirectory() as dirname:
								with chdir(a__			):
												yield dirname
class     lowerCamelCase_					(   _a			):
				pass







class     lowerCamelCase_					(   io.StringIO			):







				def       A						(    self							,       *__lowerCAmelCase							,       **__lowerCAmelCase  ):
								"""simple docstring"""
								raise OSError







				def       A						(    self							,       *__lowerCAmelCase							,       **__lowerCAmelCase  ):
								"""simple docstring"""
								raise OSError







				def       A						(    self							,       *__lowerCAmelCase							,       **__lowerCAmelCase  ):
								"""simple docstring"""
								raise OSError







				def       A						(    self							,       *__lowerCAmelCase							,       **__lowerCAmelCase  ):
								"""simple docstring"""
								return False







class     lowerCamelCase_					(   contextlib._RedirectStream			):  # type: ignore
				a__       							=	"""stdin"""







@contextlib.contextmanager
def   __lowercase       (			snake_case			):







				"""simple docstring"""






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

def   __lowercase       (			snake_case=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

				__magic_name__		:Optional[Any]   =   None
				__magic_name__		:Any   =   None

				import os

				__magic_name__		:Any   =   '''1'''

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

				import shutil

				__magic_name__		:int   =   None
				__magic_name__		:List[str]   =   None
				__magic_name__		:Any   =   None

				import subprocess

				__magic_name__		:Tuple   =   None  # type: ignore

				__magic_name__		:Tuple   =   None

				import sys

				__magic_name__		:List[Any]   =   None
				__magic_name__		:List[Any]   =   None
				__magic_name__		:Optional[Any]   =   None
				__magic_name__		:Tuple   =   None
				__magic_name__		:Any   =   None













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


UpperCamelCase__           =			logging.get_logger(__name__)

UpperCamelCase__           =			{
    "tanreinama/GPTSAN-2.8B-spout_is_uniform": (
        "https://huggingface.co/tanreinama/GPTSAN-2.8B-spout_is_uniform/resolve/main/config.json"
    ),
}

class 							__SCREAMING_SNAKE_CASE       (  _a							):
							snake_case  :   Optional[Any]      =							"""gptsan-japanese"""
							snake_case  :   Any      =							[
							    """past_key_values""",
							]
							snake_case  :   str      =							{
							    """hidden_size""": """d_model""",
							    """num_attention_heads""": """num_heads""",
							    """num_hidden_layers""": """num_layers""",
							}






							def __init__(    self	,			__lowerCAmelCase=36000	,			__lowerCAmelCase=1280	,			__lowerCAmelCase=1024	,			__lowerCAmelCase=8192	,			__lowerCAmelCase=4096	,			__lowerCAmelCase=128	,			__lowerCAmelCase=10	,			__lowerCAmelCase=0	,			__lowerCAmelCase=16	,			__lowerCAmelCase=16	,			__lowerCAmelCase=128	,			__lowerCAmelCase=0.0	,			__lowerCAmelCase=1E-5	,			__lowerCAmelCase=False	,			__lowerCAmelCase=0.0	,			__lowerCAmelCase="float32"	,			__lowerCAmelCase=False	,			__lowerCAmelCase=False	,			__lowerCAmelCase=False	,			__lowerCAmelCase=0.002	,			__lowerCAmelCase=False	,			__lowerCAmelCase=True	,			__lowerCAmelCase=35998	,			__lowerCAmelCase=35995	,			__lowerCAmelCase=35999	,			**__lowerCAmelCase	,			):
														UpperCamelCase__					  =      vocab_size
														UpperCamelCase__					  =      max_position_embeddings
														UpperCamelCase__					  =      d_model
														UpperCamelCase__					  =      d_ff
														UpperCamelCase__					  =      d_ext
														UpperCamelCase__					  =      d_spout
														UpperCamelCase__					  =      num_switch_layers
														UpperCamelCase__					  =      num_ext_layers
														UpperCamelCase__					  =      num_switch_layers + num_ext_layers
														UpperCamelCase__					  =      num_heads
														UpperCamelCase__					  =      num_experts
														UpperCamelCase__					  =      expert_capacity
														UpperCamelCase__					  =      dropout_rate
														UpperCamelCase__					  =      layer_norm_epsilon
														UpperCamelCase__					  =      router_bias
														UpperCamelCase__					  =      router_jitter_noise
														UpperCamelCase__					  =      router_dtype
														UpperCamelCase__					  =      router_ignore_padding_tokens
														UpperCamelCase__					  =      output_hidden_states
														UpperCamelCase__					  =      output_attentions
														UpperCamelCase__					  =      initializer_factor
														UpperCamelCase__					  =      output_router_logits
														UpperCamelCase__					  =      use_cache

														super().__init__(
														    separator_token_id=__lowerCAmelCase	,			pad_token_id=__lowerCAmelCase	,			eos_token_id=__lowerCAmelCase	,			**__lowerCAmelCase	,			)




