code: def update_all_selected_phrases():
      """
      Sync selected values from both the expand-table and the vocabulary list
      """
      logger.info("update selected phrases")
      global all_selected_phrases
      updated_selected_phrases = all_selected_phrases[:]
      selected_expand = [
          expand_table_source.data["res"][i]
          for i in expand_table_source.selected.indices
          if expand_table_source.data["res"][i] != ""
      ]
      selected_vocab = phrases_list.value
      logger.info("selected expand= %s", str(selected_expand))
      logger.info("selected vocab= %s", str(selected_vocab))
      logger.info(
          "current all_selected_phrases= %s", str(all_selected_phrases)
      )
      for x in all_selected_phrases:
          logger.info("x= %s", x)
          if (
              x in expand_table_source.data["res"]
              and x not in selected_expand
          ) or (
              vocab is not None
              and (vocab_dict[x] in phrases_list.options)
              and (vocab_dict[x] not in selected_vocab)
          ):
              logger.info("removing %s", x)
              updated_selected_phrases.remove(x)
      for e in selected_expand:
          if e not in updated_selected_phrases:
              logger.info("adding %s", e)
              updated_selected_phrases.append(e)
      for v in selected_vocab:
          full_v = cut_vocab_dict[v]
          if full_v not in updated_selected_phrases:
              logger.info("adding %s", full_v)
              updated_selected_phrases.append(full_v)
      all_selected_phrases = updated_selected_phrases[:]
      logger.info(
          "all_selected_phrases list was updated: %s",
          str(all_selected_phrases),
      )
  
imports: import socket
  import pickle
  import logging
  import re
  from os.path import dirname, join
  from bokeh.layouts import column, layout
  from bokeh.models import ColumnDataSource, Div, Row, CustomJS
  from bokeh.models.widgets import Button, DataTable, TableColumn, CheckboxGroup, MultiSelect
  from bokeh.models.widgets.inputs import TextInput
  from bokeh.io import curdoc
  from settings import grouping, expand_host, expand_port
label_desc: Use image node_id 4 for calling a global function with example usage: update_all_selected_phrases() without return types