



'''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     snake_case_					(     lowerCAmelCase_       ,   lowerCAmelCase_       ,   lowerCAmelCase_       ,   lowerCAmelCase_		)->		str:





       '''simple docstring'''


       _UpperCAmelCase  :						Dict			     = multiprocessing.Manager()
       _UpperCAmelCase  :						Tuple			     = manager.list()

       _UpperCAmelCase  :						Tuple			     = multiprocessing.Process(target=lowerCAmelCase_       ,   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     snake_case_					(     lowerCAmelCase_       ,   lowerCAmelCase_       ,   lowerCAmelCase_		)->		Optional[Any]:





       '''simple docstring'''


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

              _UpperCAmelCase  :						List[Any]			     = shutil.rmtree
              _UpperCAmelCase  :						Dict			     = os.rmdir
              _UpperCAmelCase  :						List[str]			     = os.chdir

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

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

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




@contextlib.contextmanager
def     snake_case_					(     lowerCAmelCase_		)->		int:





       '''simple docstring'''


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

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




@contextlib.contextmanager
def     snake_case_					(     )->		Tuple:





       '''simple docstring'''


       _UpperCAmelCase  :						str			     = WriteOnlyStringIO()
       with contextlib.redirect_stdout(lowerCAmelCase_		):
              with contextlib.redirect_stderr(lowerCAmelCase_		):
                     with redirect_stdin(lowerCAmelCase_		):
                            yield




@contextlib.contextmanager
def     snake_case_					(     )->		Tuple:





       '''simple docstring'''


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



class 							lowercase       (  _lowerCamelCase				):


 """simple docstring"""


 pass







class 							lowercase       (  io.StringIO				):


 """simple docstring"""


 def _snake_case (							self  ,*a_  ,**a_							)		->   Optional[Any]:
        raise OSError







 def _snake_case (							self  ,*a_  ,**a_							)		->   Dict:
        raise OSError







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







 def _snake_case (							self  ,*a_  ,**a_							)		->   str:
        return False







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


 """simple docstring"""


 UpperCAmelCase							=  """stdin"""







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





       '''simple docstring'''


       if root == ".":
              yield
              return
       _UpperCAmelCase  :						List[Any]			     = os.getcwd()
       os.chdir(lowerCAmelCase_		)
       try:
              yield
       except BaseException as exc:
              raise exc
       finally:
              os.chdir(lowerCAmelCase_		)




def     snake_case_					(     lowerCAmelCase_=None		)->		List[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

       _UpperCAmelCase  :						Dict			     = None
       _UpperCAmelCase  :						Tuple			     = None

       import os

       _UpperCAmelCase  :						Any			     = """1"""

       _UpperCAmelCase  :						int			     = None
       _UpperCAmelCase  :						int			     = None
       _UpperCAmelCase  :						Dict			     = None
       _UpperCAmelCase  :						int			     = None
       _UpperCAmelCase  :						str			     = None
       _UpperCAmelCase  :						Optional[int]			     = None
       _UpperCAmelCase  :						str			     = None
       _UpperCAmelCase  :						Tuple			     = None
       _UpperCAmelCase  :						int			     = None
       _UpperCAmelCase  :						List[str]			     = None
       _UpperCAmelCase  :						Optional[int]			     = None
       _UpperCAmelCase  :						Dict			     = None
       _UpperCAmelCase  :						List[str]			     = None
       _UpperCAmelCase  :						List[Any]			     = None
       _UpperCAmelCase  :						List[Any]			     = None
       _UpperCAmelCase  :						Any			     = None
       _UpperCAmelCase  :						int			     = None
       _UpperCAmelCase  :						Optional[Any]			     = None
       _UpperCAmelCase  :						Optional[int]			     = None
       _UpperCAmelCase  :						Dict			     = None
       _UpperCAmelCase  :						int			     = None
       _UpperCAmelCase  :						Dict			     = None
       _UpperCAmelCase  :						str			     = None
       _UpperCAmelCase  :						Any			     = None
       _UpperCAmelCase  :						Dict			     = None
       _UpperCAmelCase  :						List[Any]			     = None
       _UpperCAmelCase  :						Dict			     = None

       import shutil

       _UpperCAmelCase  :						Union[str, Any]			     = None
       _UpperCAmelCase  :						List[str]			     = None
       _UpperCAmelCase  :						Optional[Any]			     = None

       import subprocess

       _UpperCAmelCase  :						int			     = None  # type: ignore

       _UpperCAmelCase  :						Tuple			     = None

       import sys

       _UpperCAmelCase  :						List[str]			     = None
       _UpperCAmelCase  :						Dict			     = None
       _UpperCAmelCase  :						Optional[Any]			     = None
       _UpperCAmelCase  :						str			     = None
       _UpperCAmelCase  :						List[Any]			     = None








'''simple docstring'''






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tokenizers_available,
    is_torch_available,
)


A_							: Optional[Any]						 =	{
    """configuration_llama""": ["""LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LlamaConfig"""],
}

try:
   if not is_sentencepiece_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   A_							: List[str]						 =	["""LlamaTokenizer"""]

try:
   if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   A_							: Dict						 =	["""LlamaTokenizerFast"""]

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   A_							: Optional[int]						 =	[
       """LlamaForCausalLM""",
       """LlamaModel""",
       """LlamaPreTrainedModel""",
       """LlamaForSequenceClassification""",
   ]


if TYPE_CHECKING:
   from .configuration_llama import LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP, LlamaConfig

   try:
      if not is_sentencepiece_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_llama import LlamaTokenizer

   try:
      if not is_tokenizers_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_llama_fast import LlamaTokenizerFast

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_llama import LlamaForCausalLM, LlamaForSequenceClassification, LlamaModel, LlamaPreTrainedModel


else:
   import sys

   A_							: Any						 =	_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)



