code: def encode(self, sentences, output=False):
      for sentence in sentences:
          dataset_words = [word for (word, tag) in sentence]
          word_embeddings = self.embeddings_resolver.resolve_sentence(
              dataset_words
          )
  
          # Zip Embeddings and Tags
          words = []
          tags = []
          char_ids = []
          tag_ids = []
          is_word_start = []
          embeddings = []
  
          i = 0
  
          for item in word_embeddings:
              words.append(item.piece)
  
              if item.is_word_start:
                  assert i < len(
                      sentence
                  ), "i = {} is more or equal than length of {}, during zip with {}".format(
                      i, sentence, word_embeddings
                  )
                  tag = sentence[i][1]
                  i += 1
              else:
                  tag = self.piece_tag
  
              tag_id = self.tag2id.get(tag, len(self.tag2id))
              self.tag2id[tag] = tag_id
  
              tags.append(tag)
              tag_ids.append(tag_id)
  
              embeddings.append(item.vector)
              is_word_start.append(item.is_word_start)
  
              char_ids.append(self.get_char_indexes(item.piece))
  
          if len(sentence) > 0:
              yield {
                  "words": words,
                  "tags": tags,
                  "char_ids": char_ids,
                  "tag_ids": tag_ids,
                  "is_word_start": is_word_start,
                  "word_embeddings": np.array(
                      embeddings, dtype=np.float16
                  ),
              }
  
file_path: spark-nlp/python/tensorflow/lib/ner/dataset_encoder.py
imports: import numpy
  import os
  import tensorflow
  import string
  import random
  import math
  import sys
label_desc: Use image node_id 5 for calling the DatasetEncoder obj's underlying member method code with example usage: obj.encode(sentences, output) without return types