nodes: 0, module; 1, function_definition; 2, function_name:load; 3, parameters; 4, block; 5, identifier:self; 6, typed_parameter; 7, typed_default_parameter; 8, expression_statement; 9, expression_statement; 10, with_statement; 11, expression_statement; 12, if_statement; 13, expression_statement; 14, for_statement; 15, expression_statement; 16, expression_statement; 17, identifier:path; 18, type; 19, identifier:k; 20, type; 21, None; 22, comment:"""
          Load lexicon from Numpy array file. The top-k target ids will be sorted by increasing target id.
  
          :param path: Path to Numpy array file.
          :param k: Optionally load less items than stored in path.
          """; 23, assignment; 24, with_clause; 25, block; 26, assignment; 27, comparison_operator:k is not None; 28, block; 29, else_clause; 30, assignment; 31, pattern_list; 32, call; 33, block; 34, assignment; 35, call; 36, identifier:str; 37, generic_type; 38, identifier:load_time_start; 39, call; 40, with_item; 41, expression_statement; 42, identifier:loaded_k; 43, subscript; 44, identifier:k; 45, None; 46, expression_statement; 47, if_statement; 48, block; 49, attribute; 50, call; 51, identifier:src_id; 52, identifier:trg_ids; 53, identifier:enumerate; 54, argument_list; 55, expression_statement; 56, identifier:load_time; 57, binary_operator:time.time() - load_time_start; 58, attribute; 59, argument_list; 60, identifier:Optional; 61, type_parameter; 62, attribute; 63, argument_list; 64, as_pattern; 65, assignment; 66, attribute; 67, integer:1; 68, assignment; 69, comparison_operator:k > loaded_k; 70, block; 71, expression_statement; 72, identifier:self; 73, identifier:lex; 74, attribute; 75, argument_list; 76, identifier:_lex; 77, assignment; 78, call; 79, identifier:load_time_start; 80, identifier:logger; 81, identifier:info; 82, string:"Loaded top-%d lexicon from \"%s\" in %.4fs."; 83, identifier:top_k; 84, identifier:path; 85, identifier:load_time; 86, type; 87, identifier:time; 88, identifier:time; 89, call; 90, as_pattern_target; 91, identifier:_lex; 92, call; 93, identifier:_lex; 94, identifier:shape; 95, identifier:top_k; 96, call; 97, identifier:k; 98, identifier:loaded_k; 99, expression_statement; 100, assignment; 101, identifier:np; 102, identifier:zeros; 103, tuple; 104, keyword_argument; 105, subscript; 106, call; 107, attribute; 108, argument_list; 109, identifier:int; 110, identifier:open; 111, argument_list; 112, identifier:inp; 113, attribute; 114, argument_list; 115, identifier:min; 116, argument_list; 117, call; 118, identifier:top_k; 119, identifier:loaded_k; 120, call; 121, identifier:top_k; 122, identifier:dtype; 123, attribute; 124, attribute; 125, identifier:src_id; 126, slice; 127, attribute; 128, argument_list; 129, identifier:time; 130, identifier:time; 131, identifier:path; 132, string; 133, identifier:np; 134, identifier:load; 135, identifier:inp; 136, identifier:k; 137, identifier:loaded_k; 138, attribute; 139, argument_list; 140, identifier:len; 141, argument_list; 142, identifier:_lex; 143, identifier:dtype; 144, identifier:self; 145, identifier:lex; 146, identifier:np; 147, identifier:sort; 148, subscript; 149, string_content:rb; 150, identifier:logger; 151, identifier:warning; 152, concatenated_string; 153, identifier:k; 154, identifier:loaded_k; 155, attribute; 156, identifier:trg_ids; 157, slice; 158, string:"Can not load top-%d translations from lexicon that "; 159, string:"contains at most %d entries per source."; 160, identifier:self; 161, identifier:vocab_source; 162, identifier:top_k
code: def load(self, path: str, k: Optional[int] = None):
          """
          Load lexicon from Numpy array file. The top-k target ids will be sorted by increasing target id.
  
          :param path: Path to Numpy array file.
          :param k: Optionally load less items than stored in path.
          """
          load_time_start = time.time()
          with open(path, 'rb') as inp:
              _lex = np.load(inp)
          loaded_k = _lex.shape[1]
          if k is not None:
              top_k = min(k, loaded_k)
              if k > loaded_k:
                  logger.warning("Can not load top-%d translations from lexicon that "
                                 "contains at most %d entries per source.", k, loaded_k)
          else:
              top_k = loaded_k
          self.lex = np.zeros((len(self.vocab_source), top_k), dtype=_lex.dtype)
          for src_id, trg_ids in enumerate(_lex):
              self.lex[src_id, :] = np.sort(trg_ids[:top_k])
          load_time = time.time() - load_time_start
          logger.info("Loaded top-%d lexicon from \"%s\" in %.4fs.", top_k, path, load_time)