(self, opt, model_id, tokenizer_opt=None, load=False,
                 timeout=-1, on_timeout="to_cpu", model_root="./")
Args:
                opt: (dict) options for the Translator
                model_id: (int) model id
                tokenizer_opt: (dict) options for the tokenizer or None
                load: (bool) whether to load the model during __init__
                timeout: (int) seconds before running `do_timeout`
                         Negative values means no timeout
                on_timeout: (str) in ["to_cpu", "unload"] set what to do on
                            timeout (see function `do_timeout`)
                model_root: (str) path to the model directory
                            it must contain de model and tokenizer file
Args:
                opt: (dict) options for the Translator
                model_id: (int) model id
                tokenizer_opt: (dict) options for the tokenizer or None
                load: (bool) whether to load the model during __init__
                timeout: (int) seconds before running `do_timeout`
                         Negative values means no timeout
                on_timeout: (str) in ["to_cpu", "unload"] set what to do on
                            timeout (see function `do_timeout`)
                model_root: (str) path to the model directory
                            it must contain de model and tokenizer file
Args : opt : ( dict ) options for the Translator model_id : ( int ) model id tokenizer_opt : ( dict ) options for the tokenizer or None load : ( bool ) whether to load the model during __init__ timeout : ( int ) seconds before running do_timeout Negative values means no timeout on_timeout : ( str ) in [ to_cpu unload ] set what to do on timeout ( see function do_timeout ) model_root : ( str ) path to the model directory it must contain de model and tokenizer file
def __init__(self, opt, model_id, tokenizer_opt=None, load=False,
                 timeout=-1, on_timeout="to_cpu", model_root="./"):
        """
            Args:
                opt: (dict) options for the Translator
                model_id: (int) model id
                tokenizer_opt: (dict) options for the tokenizer or None
                load: (bool) whether to load the model during __init__
                timeout: (int) seconds before running `do_timeout`
                         Negative values means no timeout
                on_timeout: (str) in ["to_cpu", "unload"] set what to do on
                            timeout (see function `do_timeout`)
                model_root: (str) path to the model directory
                            it must contain de model and tokenizer file

        """
        self.model_root = model_root
        self.opt = self.parse_opt(opt)
        if self.opt.n_best > 1:
            raise ValueError("Values of n_best > 1 are not supported")

        self.model_id = model_id
        self.tokenizer_opt = tokenizer_opt
        self.timeout = timeout
        self.on_timeout = on_timeout

        self.unload_timer = None
        self.user_opt = opt
        self.tokenizer = None
        self.logger = init_logger(self.opt.log_file)
        self.loading_lock = threading.Event()
        self.loading_lock.set()

        if load:
            self.load()
def __init__ ( self , opt , model_id , tokenizer_opt = None , load = False , timeout = - 1 , on_timeout = "to_cpu" , model_root = "./" ) : self . model_root = model_root self . opt = self . parse_opt ( opt ) if self . opt . n_best > 1 : raise ValueError ( "Values of n_best > 1 are not supported" ) self . model_id = model_id self . tokenizer_opt = tokenizer_opt self . timeout = timeout self . on_timeout = on_timeout self . unload_timer = None self . user_opt = opt self . tokenizer = None self . logger = init_logger ( self . opt . log_file ) self . loading_lock = threading . Event ( ) self . loading_lock . set ( ) if load : self . load ( )