code: def reseg_token_label(
      tokenizer, tokens: List[str], labels: List[str] = None
  ):
      """
      Convert segments and labels of sequence labeling samples into tokens
      based on the vocab of tokenizer.
      """
      if labels:
          if len(tokens) != len(labels):
              raise ValueError(
                  "The length of tokens must be same with labels"
              )
          ret_tokens = []
          ret_labels = []
          for token, label in zip(tokens, labels):
              sub_token = tokenizer._tokenize(token)
              if len(sub_token) == 0:
                  continue
              ret_tokens.extend(sub_token)
              ret_labels.append(label)
              if len(sub_token) < 2:
                  continue
              sub_label = label
              if label.startswith("B-"):
                  sub_label = "I-" + label[2:]
              ret_labels.extend([sub_label] * (len(sub_token) - 1))
  
          if len(ret_tokens) != len(ret_labels):
              raise ValueError(
                  "The length of ret_tokens can't match with labels"
              )
          return ret_tokens, ret_labels
      else:
          ret_tokens = []
          for token in tokens:
              sub_token = tokenizer._tokenize(token)
              if len(sub_token) == 0:
                  continue
              ret_tokens.extend(sub_token)
              if len(sub_token) < 2:
                  continue
          return ret_tokens, None
  
imports: import base64
  import contextlib
  import hashlib
  import importlib
  import math
  import os
  import socket
  import sys
  import tempfile
  import time
  import traceback
  import types
  from typing import Generator
  from typing import List
  from urllib.parse import urlparse
  import cv2
  import numpy
  import packaging.version
  import requests
  import paddlehub.env
  import paddlehub.utils
  from paddlehub.utils.log import logger
label_desc: Use image node_id 18 for calling a global function with example usage: reseg_token_label(tokenizer, tokens, labels) and returns: ret_tokens,  ret_labels, ret_tokens,  None