class_docstr: Abstract base class for QA Datasets with common utility methods 
class_docstr_tok: ["Abstract","base","class","for","QA","Datasets","with","common","utility","methods"]
docstr: For a particular position, identify which doc_span gives the most context around token
  Helper function for check_is_max_context; see check_is_max_context for more details
docstr_tok: ["For","a","particular","position",",","identify","which","doc_span","gives","the","most","context","around","token","Helper","function","for","check_is_max_context",";","see","check_is_max_context","for","more","details"]
code: def get_best_span_index(doc_spans, position):
      """
      For a particular position, identify which doc_span gives the most context around token
      Helper function for check_is_max_context; see check_is_max_context for more details
      """
  
      best_score = None
      best_span_index = None
      for span_index, doc_span in enumerate(doc_spans):
          end = doc_span.start + doc_span.length - 1
          if position < doc_span.start:
              continue
          if position > end:
              continue
          num_left_context = position - doc_span.start
          num_right_context = end - position
          score = (
              min(num_left_context, num_right_context)
              + 0.01 * doc_span.length
          )
          if best_score is None or score > best_score:
              best_score = score
              best_span_index = span_index
  
      return best_span_index
  
imports: import collections
  import pickle
  from functools import lru_cache
  from typing import List
  import psutil
  import torch
  from nemo.collections.nlp.data.data_utils import is_whitespace
  from nemo.collections.nlp.data.question_answering.data_processor.qa_processing import EVALUATION_MODE, INFERENCE_MODE, TRAINING_MODE
  from nemo.core.classes import Dataset
  from nemo.utils import logging
label_desc: Use image node_id 7 for calling the QADataset obj's underlying member method code with example usage: obj.get_best_span_index(doc_spans, position) and returns: best_span_index