
"""simple docstring"""




import contextlib
import faulthandler
import io
import multiprocessing
import os
import platform
import signal
import tempfile



def 							a__ (				lowerCAmelCase	:       Tuple       ,    lowerCAmelCase	:       str       ,    lowerCAmelCase	:       int       ,    lowerCAmelCase	:       Optional[int]		):






     '''simple docstring'''
     UpperCAmelCase__							: List[Any] 							=						multiprocessing.Manager()
     UpperCAmelCase__							: str 							=						manager.list()

     UpperCAmelCase__							: List[str] 							=						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 							a__ (				lowerCAmelCase	:       Union[str, Any]       ,    lowerCAmelCase	:       int       ,    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__							: List[str] 							=						os.rmdir
          UpperCAmelCase__							: Union[str, Any] 							=						os.chdir

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

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



@contextlib.contextmanager
def 							a__ (				lowerCAmelCase	:       int		):






     '''simple docstring'''


     def signal_handler(lowerCAmelCase	:       Union[str, Any]       ,    lowerCAmelCase	:       str		):
          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 							a__ (				):






     '''simple docstring'''
     UpperCAmelCase__							: List[str] 							=						WriteOnlyStringIO()
     with contextlib.redirect_stdout(lowerCamelCase__		):
          with contextlib.redirect_stderr(lowerCamelCase__		):
               with redirect_stdin(lowerCamelCase__		):
                    yield



@contextlib.contextmanager
def 							a__ (				):






     '''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  lowerCAmelCase__       (      self ,			*__UpperCamelCase ,			**__UpperCamelCase  )->					Union[str, Any]:
          raise OSError



     def  lowerCAmelCase__       (      self ,			*__UpperCamelCase ,			**__UpperCamelCase  )->					Optional[Any]:
          raise OSError



     def  lowerCAmelCase__       (      self ,			*__UpperCamelCase ,			**__UpperCamelCase  )->					Dict:
          raise OSError



     def  lowerCAmelCase__       (      self ,			*__UpperCamelCase ,			**__UpperCamelCase  )->					str:
          return False







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


     '''simple docstring'''





     _A								=							"stdin"





@contextlib.contextmanager
def 							a__ (				lowerCAmelCase	:       Dict		):






     '''simple docstring'''


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



def 							a__ (				lowerCAmelCase	:       List[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

     UpperCAmelCase__							: Optional[int] 							=						None
     UpperCAmelCase__							: int 							=						None

     import os

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

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

     import shutil

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

     import subprocess

     UpperCAmelCase__							: Optional[Any] 							=						None  # type: ignore

     UpperCAmelCase__							: List[str] 							=						None

     import sys

     UpperCAmelCase__							: int 							=						None
     UpperCAmelCase__							: Dict 							=						None
     UpperCAmelCase__							: List[str] 							=						None
     UpperCAmelCase__							: Optional[Any] 							=						None
     UpperCAmelCase__							: Any 							=						None





"""simple docstring"""




from typing import TYPE_CHECKING

from ....utils import _LazyModule


A__      :	List[str]          =    {"""tokenization_tapex""": ["""TapexTokenizer"""]}


if TYPE_CHECKING:
    from .tokenization_tapex import TapexTokenizer


else:
    import sys

    A__      :	Any          =    _LazyModule(__name__, globals()["""__file__"""], _import_structure)



