
# 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						(   lowercase_			,			lowercase_			,			lowercase_			,			lowercase_ )		->						Tuple:


  '''simple docstring'''






  lowercase__	: Dict     		=   multiprocessing.Manager()
  lowercase__	: Optional[int]     		=   manager.list()

  lowercase__	: str     		=   multiprocessing.Process(target=lowercase_			,			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						(   lowercase_			,			lowercase_			,			lowercase_ )		->						Tuple:


  '''simple docstring'''






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

    lowercase__	: Optional[int]     		=   shutil.rmtree
    lowercase__	: Dict     		=   os.rmdir
    lowercase__	: int     		=   os.chdir

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

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

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

@contextlib.contextmanager
def 		UpperCamelCase						(   lowercase_ )		->						str:


  '''simple docstring'''






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

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

@contextlib.contextmanager
def 		UpperCamelCase						(   )		->						Dict:


  '''simple docstring'''






  lowercase__	: Union[str, Any]     		=   WriteOnlyStringIO()
  with contextlib.redirect_stdout(lowercase_ ):
    with contextlib.redirect_stderr(lowercase_ ):
      with redirect_stdin(lowercase_ ):
        yield

@contextlib.contextmanager
def 		UpperCamelCase						(   )		->						Union[str, Any]:


  '''simple docstring'''






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



class    _snake_case (						UpperCAmelCase_				):
 pass



class    _snake_case (						io.StringIO				):


 def   lowercase__  (       self       ,	*SCREAMING_SNAKE_CASE_       ,	**SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   raise OSError


 def   lowercase__  (       self       ,	*SCREAMING_SNAKE_CASE_       ,	**SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   raise OSError


 def   lowercase__  (       self       ,	*SCREAMING_SNAKE_CASE_       ,	**SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   raise OSError



 def   lowercase__  (       self       ,	*SCREAMING_SNAKE_CASE_       ,	**SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   return False



class    _snake_case (						contextlib._RedirectStream				):  # type: ignore
 __lowerCAmelCase	:  Any	   =      'stdin'

@contextlib.contextmanager
def 		UpperCamelCase						(   lowercase_ )		->						Optional[int]:


  '''simple docstring'''






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



def 		UpperCamelCase						(   lowercase_=None )		->						Union[str, Any]:


  '''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

  lowercase__	: Union[str, Any]     		=   None
  lowercase__	: int     		=   None

  import os

  lowercase__	: Union[str, Any]     		=   """1"""

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

  import shutil

  lowercase__	: Any     		=   None
  lowercase__	: Optional[int]     		=   None
  lowercase__	: Any     		=   None

  import subprocess

  lowercase__	: Union[str, Any]     		=   None  # type: ignore

  lowercase__	: Optional[int]     		=   None

  import sys

  lowercase__	: Dict     		=   None
  lowercase__	: Dict     		=   None
  lowercase__	: Tuple     		=   None
  lowercase__	: Optional[Any]     		=   None
  lowercase__	: Any     		=   None








lowerCamelCase__     :		List[str]        = """
# Installazione di Transformers
! pip install transformers datasets
# Per installare dalla fonte invece dell'ultima versione rilasciata, commenta il comando sopra e
# rimuovi la modalità commento al comando seguente.
# ! pip install git+https://github.com/huggingface/transformers.git
"""

lowerCamelCase__     :		List[Any]        = [{"""type""": """code""", """content""": INSTALL_CONTENT}]
lowerCamelCase__     :		int        = {
    """{processor_class}""": """FakeProcessorClass""",
    """{model_class}""": """FakeModelClass""",
    """{object_class}""": """FakeObjectClass""",
}






