code: def recursive_split(
      segment, bpe_codes, vocab, separator, final=False
  ):
      """Recursively split segment into smaller units (by reversing BPE merges)
      until all units are either in-vocabulary, or cannot be split futher.
      """
  
      try:
          if final:
              left, right = bpe_codes[segment + "</w>"]
              right = right[:-4]
          else:
              left, right = bpe_codes[segment]
      except:
          # sys.stderr.write('cannot split {0} further.\n'.format(segment))
          yield segment
          return
  
      if left + separator in vocab:
          yield left
      else:
          for item in recursive_split(
              left, bpe_codes, vocab, separator, False
          ):
              yield item
  
      if (final and right in vocab) or (
          not final and right + separator in vocab
      ):
          yield right
      else:
          for item in recursive_split(
              right, bpe_codes, vocab, separator, final
          ):
              yield item
  
imports: from __future__ import unicode_literals, division
  import sys
  import codecs
  import io
  import argparse
  import json
  import re
  from collections import defaultdict
  from io import open
label_desc: Use image node_id 4 for calling a global function with example usage: recursive_split(segment, bpe_codes, vocab, separator, final) without return types