class_docstr: 用于维护处于 topk 的 key, value 对。
  
  :param int topk: 整数，-1 表示所有数据都是 topk 的; 如果是 0, 表示没有任何数据是满足 topk 的。
class_docstr_tok: ["\u7528\u4e8e\u7ef4\u62a4\u5904\u4e8e","topk","\u7684","key",",","value","\u5bf9\u3002",":","param","int","topk",":","\u6574\u6570\uff0c-1","\u8868\u793a\u6240\u6709\u6570\u636e\u90fd\u662f","topk","\u7684",";","\u5982\u679c\u662f","0",",","\u8868\u793a\u6ca1\u6709\u4efb\u4f55\u6570\u636e\u662f\u6ee1\u8db3","topk","\u7684\u3002"]
docstr: 将 key/value 推入 topk 的 queue 中，以 value 为标准，如果满足 topk 则保留此次推入的信息，同时如果新推入的数据将之前的数据给
  挤出了 topk ，则会返回被挤出的 (key, value)；如果返回为 (None, None)，说明满足 topk 且没有数据被挤出。如果不满足 topk ，则返回
  推入的 (key, value) 本身。这里排序只根据 value 是否更大了判断，因此如果有的情况是越小越好，请在输入前取负号。
  
  :param str key:
  :param float value: 如果为 None， 则不做任何操作。
  :return: （1）返回输入的 (key, value) ，说明不满足 topk; (2) 返回(None, None)，说明满足 topk 且没有被挤出过去的记录; (3)
      返回非输入的 (key, value) , 说明输入满足 topk，且挤出了之前的记录。
docstr_tok: ["\u5c06","key\/value","\u63a8\u5165","topk","\u7684","queue","\u4e2d\uff0c\u4ee5","value","\u4e3a\u6807\u51c6\uff0c\u5982\u679c\u6ee1\u8db3","topk","\u5219\u4fdd\u7559\u6b64\u6b21\u63a8\u5165\u7684\u4fe1\u606f\uff0c\u540c\u65f6\u5982\u679c\u65b0\u63a8\u5165\u7684\u6570\u636e\u5c06\u4e4b\u524d\u7684\u6570\u636e\u7ed9","\u6324\u51fa\u4e86","topk","\uff0c\u5219\u4f1a\u8fd4\u56de\u88ab\u6324\u51fa\u7684","(","key",",","value",")","\uff1b\u5982\u679c\u8fd4\u56de\u4e3a","(","None",",","None",")","\uff0c\u8bf4\u660e\u6ee1\u8db3","topk","\u4e14\u6ca1\u6709\u6570\u636e\u88ab\u6324\u51fa\u3002\u5982\u679c\u4e0d\u6ee1\u8db3","topk","\uff0c\u5219\u8fd4\u56de","\u63a8\u5165\u7684","(","key",",","value",")","\u672c\u8eab\u3002\u8fd9\u91cc\u6392\u5e8f\u53ea\u6839\u636e","value","\u662f\u5426\u66f4\u5927\u4e86\u5224\u65ad\uff0c\u56e0\u6b64\u5982\u679c\u6709\u7684\u60c5\u51b5\u662f\u8d8a\u5c0f\u8d8a\u597d\uff0c\u8bf7\u5728\u8f93\u5165\u524d\u53d6\u8d1f\u53f7\u3002",":","param","str","key",":",":","param","float","value",":","\u5982\u679c\u4e3a","None\uff0c","\u5219\u4e0d\u505a\u4efb\u4f55\u64cd\u4f5c\u3002",":","return",":","\uff081\uff09\u8fd4\u56de\u8f93\u5165\u7684","(","key",",","value",")","\uff0c\u8bf4\u660e\u4e0d\u6ee1\u8db3","topk",";","(","2",")","\u8fd4\u56de","(","None",",","None",")","\uff0c\u8bf4\u660e\u6ee1\u8db3","topk","\u4e14\u6ca1\u6709\u88ab\u6324\u51fa\u8fc7\u53bb\u7684\u8bb0\u5f55",";","(","3",")","\u8fd4\u56de\u975e\u8f93\u5165\u7684","(","key",",","value",")",",","\u8bf4\u660e\u8f93\u5165\u6ee1\u8db3","topk\uff0c\u4e14\u6324\u51fa\u4e86\u4e4b\u524d\u7684\u8bb0\u5f55\u3002"]
code: def push(
      self, key, value
  ) -> Optional[Tuple[Union[str, None], Union[float, None]]]:
      """
      将 key/value 推入 topk 的 queue 中，以 value 为标准，如果满足 topk 则保留此次推入的信息，同时如果新推入的数据将之前的数据给
      挤出了 topk ，则会返回被挤出的 (key, value)；如果返回为 (None, None)，说明满足 topk 且没有数据被挤出。如果不满足 topk ，则返回
      推入的 (key, value) 本身。这里排序只根据 value 是否更大了判断，因此如果有的情况是越小越好，请在输入前取负号。
  
      :param str key:
      :param float value: 如果为 None， 则不做任何操作。
      :return: （1）返回输入的 (key, value) ，说明不满足 topk; (2) 返回(None, None)，说明满足 topk 且没有被挤出过去的记录; (3)
          返回非输入的 (key, value) , 说明输入满足 topk，且挤出了之前的记录。
      """
      if value is None:
          return key, value
      if self.topk < 0:
          return None, None
      if self.topk == 0:
          return key, value
      if len(self.topk_dict) < self.topk:
          self.topk_dict[key] = value
          return None, None
      min_key = min(self.topk_dict, key=lambda x: self.topk_dict[x])
      if self.topk_dict[min_key] > value:
          return key, value
      else:
          min_value = self.topk_dict.pop(min_key)
          self.topk_dict[key] = value
          return min_key, min_value
  
imports: import json
  import os
  from copy import deepcopy
  from pathlib import Path
  from typing import Optional, Dict, Tuple, Callable, Union
  from ...envs.distributed import rank_zero_rm
  from fastNLP.core.log import logger
  from fastNLP.envs import FASTNLP_LAUNCH_TIME
  from fastNLP.envs import rank_zero_call
  from fastNLP.envs.env import FASTNLP_EVALUATE_RESULT_FILENAME
  from .has_monitor_callback import ResultsMonitor
label_desc: Use image node_id 2 for calling the TopkQueue obj's underlying member method code with example usage: obj.push(key, value) and returns: key,  value, None,  None, key,  value, None,  None, key,  value, min_key,  min_value