code: def get_subwords_batches(
      doc: Doc, config: Config, tok: AutoTokenizer
  ) -> np.ndarray:
      """
      Turns a list of subwords to a list of lists of subword indices
      of max length == batch_size (or shorter, as batch boundaries
      should match sentence boundaries). Each batch is enclosed in cls and sep
      special tokens.
  
      Returns:
          batches of bert tokens [n_batches, batch_size]
      """
      batch_size = (
          config.bert_window_size - 2
      )  # to save space for CLS and SEP
  
      subwords: List[str] = doc["subwords"]
      subwords_batches = []
      start, end = 0, 0
  
      while end < len(subwords):
          end = min(end + batch_size, len(subwords))
  
          # Move back till we hit a sentence end
          if end < len(subwords):
              sent_id = doc["sent_id"][doc["word_id"][end]]
              while (
                  end
                  and doc["sent_id"][doc["word_id"][end - 1]] == sent_id
              ):
                  end -= 1
  
          length = end - start
          batch = (
              [tok.cls_token] + subwords[start:end] + [tok.sep_token]
          )
          batch_ids = [-1] + list(range(start, end)) + [-1]
  
          # Padding to desired length
          # -1 means the token is a special token
          batch += [tok.pad_token] * (batch_size - length)
          batch_ids += [-1] * (batch_size - length)
  
          subwords_batches.append(
              [tok.convert_tokens_to_ids(token) for token in batch]
          )
          start += length
  
      return np.array(subwords_batches)
  
imports: import logging
  from typing import List, Tuple
  import numpy
  from transformers import AutoModel, AutoTokenizer
  from stanza.models.coref.config import Config
  from stanza.models.coref.const import Doc
label_desc: Use image node_id 1 for calling a global function with example usage: get_subwords_batches(doc, config, tok) and returns: np