code: def round_to_nearest_start_and_end(
      label, token_starts, token_ends, text
  ):
      # Update label start / end / text to align with nearest token start_token and end
      # Applies in-place modification to `label` obj.
      end_distances = np.abs(token_ends - label["end"])
      label["end"] = token_ends[np.argmin(end_distances)]
  
      token_starts = token_starts[token_starts < label["end"]]
      start_distances = np.abs(
          np.asarray(token_starts) - label["start"]
      )
      label["start"] = token_starts[np.argmin(start_distances)]
  
      label["text"] = text[label["start"] : label["end"]]
  
file_path: finetune/finetune/encoding/sequence_encoder.py
imports: import warnings
  import numpy
  from finetune.encoding.input_encoder import get_spacy
label_desc: Use image node_id 3 for calling a global function with example usage: round_to_nearest_start_and_end(label, token_starts, token_ends, text) without return types