docstr: Given a set of all retrieved docs, determine best fitting document.
  
  :param all_docs:
      list of all retrieved Documents
  :param labels:
      labels for the current example
  
  :return (best_f1, best_doc, best_doc_idx):
      return the best document, along with the f1 overlap and index into all_docs
docstr_tok: ["Given","a","set","of","all","retrieved","docs",",","determine","best","fitting","document",".",":","param","all_docs",":","list","of","all","retrieved","Documents",":","param","labels",":","labels","for","the","current","example",":","return","(","best_f1",",","best_doc",",","best_doc_idx",")",":","return","the","best","document",",","along","with","the","f1","overlap","and","index","into","all_docs"]
code: def get_best_doc(
      self, all_docs: List[Document], labels: List[str]
  ) -> Tuple[Optional[float], Optional[Document], Optional[int]]:
      """
      Given a set of all retrieved docs, determine best fitting document.
  
      :param all_docs:
          list of all retrieved Documents
      :param labels:
          labels for the current example
  
      :return (best_f1, best_doc, best_doc_idx):
          return the best document, along with the f1 overlap and index into all_docs
      """
      docs = []
      for i, d in enumerate(all_docs):
          if d.startswith("."):
              d = d[2:]
          try:
              docs += [(i, s) for s in nltk.sent_tokenize(d)]
          except IndexError:
              # Something's up with the NLTK Sentence tokenizer here.
              docs += [(i, s) for s in d.split(".")]
      f1s, inds = torch.FloatTensor(
          [F1Metric.compute(labels[0], [d]).value() for _, d in docs]
      ).topk(len(docs))
      best_doc = None
      best_doc_idx = None
      best_f1 = None
      for f1, ind in zip(f1s, inds):
          if (
              self.threshold < f1 < 1.0
              and labels[0] not in docs[ind][1]
          ):
              best_doc = docs[ind][1]
              best_doc_idx = docs[ind][0]
              best_f1 = f1.item()
              break
  
      return best_f1, best_doc, best_doc_idx
  
imports: import nltk
  import os
  import random
  import torch
  from typing import Optional, List, Tuple
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from parlai.agents.rag.retrievers import RetrieverType, Document
  from parlai.agents.fid.fid import SearchQuerySearchEngineFiDAgent
  from parlai.agents.tfidf_retriever.utils import filter_word
  from parlai.core.agents import Agent, create_agent
  from parlai.core.dict import DictionaryAgent
  from parlai.core.message import Message
  from parlai.core.metrics import F1Metric
  from parlai.core.script import ParlaiScript
  from parlai.core.worlds import create_task
  from parlai.scripts.eval_model import setup_args, get_task_world_logs
  from parlai.tasks.wizard_of_wikipedia.agents import TOKEN_KNOWLEDGE, TOKEN_END_KNOWLEDGE
  import parlai.utils.logging
  from parlai.utils.misc import TimeLogger
  from parlai.utils.world_logging import WorldLogger
  from projects.blenderbot2.agents.modules import BB2SearchQuerySearchEngineRetriever
label_desc: Use image node_id 5 for calling the OverlapAgent obj's underlying member method code with example usage: obj.get_best_doc(all_docs, labels) and returns: best_f1,  best_doc,  best_doc_idx