code: def offset_to_token_idx_vecorized(token_offsets, ch_idx):
      """Returns the idx of the token at the given character idx"""
      ################
      ################
      ##################
      # TODO CHECK THIS fct thoroughly - This must be bulletproof and inlcude start and end of sequence checks
      # todo Possibly this function does not work for Natural Questions and needs adjustments
      ################
      ################
      ##################
      # case ch_idx is at end of tokens
      if ch_idx >= np.max(token_offsets):
          # TODO check "+ 1" (it is needed for making end indices compliant with old offset_to_token_idx() function)
          # check weather end token is incluse or exclusive
          idx = np.argmax(token_offsets) + 1
      # looking for the first occurence of token_offsets larger than ch_idx and taking one position to the left.
      # This is needed to overcome n special_tokens at start of sequence
      # and failsafe matching (the character start might not always coincide with a token offset, e.g. when starting at whitespace)
      else:
          idx = np.argmax(token_offsets > ch_idx) - 1
      return idx
  
file_path: FARM/farm/data_handler/samples.py
imports: from transformers.models.bert.tokenization_bert import whitespace_tokenize
  from farm.visual.ascii.images import SAMPLE
  import numpy
  import logging
label_desc: Use image node_id 6 for calling a global function with example usage: offset_to_token_idx_vecorized(token_offsets, ch_idx) and returns: idx