code: def check_vocab_and_split(orig, bpe_codes, vocab, separator):
      """Check for each segment in word if it is in-vocabulary,
      and segment OOV segments into smaller units by reversing the BPE merge operations
      """
  
      out = []
  
      for segment in orig[:-1]:
          if segment + separator in vocab:
              out.append(segment)
          else:
              # sys.stderr.write('OOV: {0}\n'.format(segment))
              for item in recursive_split(
                  segment, bpe_codes, vocab, separator, False
              ):
                  out.append(item)
  
      segment = orig[-1]
      if segment in vocab:
          out.append(segment)
      else:
          # sys.stderr.write('OOV: {0}\n'.format(segment))
          for item in recursive_split(
              segment, bpe_codes, vocab, separator, True
          ):
              out.append(item)
  
      return out
  
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 5 for calling a global function with example usage: check_vocab_and_split(orig, bpe_codes, vocab, separator) and returns: out