code: def generate_bar_example(
      num_topics=10,
      num_documents=500,
      num_words_per_doc=100,
      alpha=1,
      beta=1,
      seed=None,
  ):
      """
      Generate the classic "bars" example, a synthetic data set of small
      black 5x5 pixel images with a single white bar that is either horizontal
      or vertical.
  
      See Steyvers' MATLAB Topic Modeling Toolbox,
      http://psiexp.ss.uci.edu/research/programs_data/exampleimages1.html,
  
      and the original paper:
      Griffiths, T., & Steyvers, M. (2004). Finding Scientific Topics.
      Proceedings of the National Academy of Sciences, 101 (suppl. 1), 5228-5235.
  
      Returns
      -------
      out : SArray
          Each element represents a 'document' where the words are strings that
          represent a single pixel in the image in a colon-separated format.
          For example, 'horizontal_location:vertical_location'. Each word is
          associated with a count of the number of generated occurrences.
      """
  
      width = 5
  
      vocab_size = width * width
      rng = random.Random()
      if seed is not None:
          rng.seed(seed)
  
      zeros = [[0 for i in range(width)] for j in range(width)]
      topic_squares = [zeros for i in range(num_topics)]
      for i in range(width):
          for j in range(width):
              topic_squares[i][i][j] = 1.0 / width
      for i in range(width):
          for j in range(width):
              topic_squares[width + i][j][i] = 1.0 / width
      topics = []
      for k in range(num_topics):
          topics.append(list(_itertools.chain(*topic_squares[k])))
  
      def weighted_choice(probs):
          total = sum(probs)
          r = rng.uniform(0, total)
          upto = 0
          for i, w in enumerate(probs):
              if upto + w > r:
                  return i
              upto += w
          assert False, "Shouldn't get here"
  
      documents = []
      thetas = []
      for d in range(num_documents):
          doc = [0 for i in range(width * width)]
          topic_dist = [
              rng.gammavariate(1, 1) for k in range(num_topics)
          ]
          topic_dist = [z / sum(topic_dist) for z in topic_dist]
          for i in range(num_words_per_doc):
              k = weighted_choice(topic_dist)
              w = weighted_choice(topics[k])
              doc[w] += 1
          thetas.append(topic_dist)
          documents.append(doc)
  
      sparse_documents = []
      for d in documents:
          sd = {}
          for i in range(width):
              for j in range(width):
                  k = str(i) + "," + str(j)
                  sd[k] = d[i * width + j]
          sparse_documents.append(sd)
      bow_documents = turicreate.SArray(sparse_documents)
      return bow_documents
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import os
  import tempfile
  import shutil
  import unittest
  import turicreate
  from turicreate.toolkits._main import ToolkitError
  from turicreate.toolkits.topic_model import topic_model
  from turicreate.toolkits.text_analytics import parse_sparse
  from turicreate.toolkits.text_analytics import parse_docword
  from turicreate.toolkits.topic_model import perplexity
  from .None import util
  import time
  import random
  import numpy
  import itertools
label_desc: Use image node_id 1 for calling a global function with example usage: generate_bar_example(num_topics, num_documents, num_words_per_doc, alpha, beta, seed) and returns: bow_documents, i