class_docstr: Run compilation on local machine
  
  Parameters
  ----------
  timeout: float
      The timeout of a compilation
  n_parallel: int
      The number of tasks run in parallel. "None" will use all cpu cores
  build_kwargs: dict
      If supplied, additional kwargs passed to build_func. Overrides any build_kwargs supplied
      by the Runner.
  build_func: callable or str
      If is 'default', use default build function
      If is 'ndk', use function for android ndk
      If id 'stackvm', use function for stackvm
      If is callable, use it as custom build function, expect lib_format field.
  do_fork: bool
      If False, do not fork when building. Requires n_parallel=1.
  runtime: Optional[Runtime]
      Specify the runtime to generate artifacts for
class_docstr_tok: ["Run","compilation","on","local","machine","Parameters","--","--","--","--","--","timeout",":","float","The","timeout","of","a","compilation","n_parallel",":","int","The","number","of","tasks","run","in","parallel",".","``","None","''","will","use","all","cpu","cores","build_kwargs",":","dict","If","supplied",",","additional","kwargs","passed","to","build_func",".","Overrides","any","build_kwargs","supplied","by","the","Runner",".","build_func",":","callable","or","str","If","is","'default","'",",","use","default","build","function","If","is","'ndk","'",",","use","function","for","android","ndk","If","id","'stackvm","'",",","use","function","for","stackvm","If","is","callable",",","use","it","as","custom","build","function",",","expect","lib_format","field",".","do_fork",":","bool","If","False",",","do","not","fork","when","building",".","Requires","n_parallel=1",".","runtime",":","Optional","[","Runtime","]","Specify","the","runtime","to","generate","artifacts","for"]
code: def __init__(
      self,
      timeout=10,
      n_parallel=None,
      build_kwargs=None,
      build_func="default",
      do_fork=False,
      runtime=None,
  ):
      super(LocalBuilder, self).__init__(
          timeout, n_parallel, build_kwargs
      )
  
      if isinstance(build_func, str):
          if build_func == "default":
              build_func = tar.tar
          elif build_func == "ndk":
              build_func = ndk.create_shared
          elif build_func == "stackvm":
              build_func = stackvm.build
          else:
              raise ValueError("Invalid build_func" + build_func)
      self.build_func = _WrappedBuildFunc(build_func, runtime)
      if not do_fork:
          assert n_parallel in (
              None,
              1,
          ), f"if do_fork=False, need n_parallel=None or 1; got {n_parallel}"
      self.executor = PopenPoolExecutor(
          timeout=timeout,
          initializer=reset_global_scope,
          initargs=(AutotvmGlobalScope.current,),
      )
      self.tmp_dir = tempfile.mkdtemp()
  
imports: import contextlib
  import logging
  import os
  import shutil
  import tempfile
  import threading
  import time
  import traceback
  import typing
  import warnings
  from collections import namedtuple
  from random import getrandbits
  import tvm._ffi
  import tvm.ir.transform
  from tvm import nd
  from tvm import rpc
  from tvm.autotvm.env import AutotvmGlobalScope, reset_global_scope
  from tvm.contrib import ndk, stackvm, tar
  from tvm.contrib.popen_pool import PopenPoolExecutor
  from tvm.driver import build
  from tvm.error import TVMError
  from tvm.target import Target
  from ..env import AutotvmGlobalScope
  from ..task.space import InstantiationError
  from ..utils import get_const_tuple
  from .measure import Builder, MeasureErrorNo, MeasureResult, Runner
label_desc: Use image node_id 1 to create a new LocalBuilder object from inherited base classes: Builder with example: obj = LocalBuilder(timeout, n_parallel, build_kwargs, build_func, do_fork, runtime)