code: def dirichlet_process(alpha):
      """Demo of stochastic while loop for stick breaking construction."""
  
      def cond(k, beta_k):
          # End while loop (return False) when flip is heads.
          flip = Bernoulli(beta_k)
          return tf.cast(1 - flip, tf.bool)
  
      def body(k, beta_k):
          beta_k = Beta(1.0, alpha)
          return k + 1, beta_k
  
      k = tf.constant(0)
      beta_k = Beta(1.0, alpha)
      stick_num, stick_beta = tf.while_loop(
          cond, body, loop_vars=[k, beta_k]
      )
      return stick_num
  
file_path: edward/examples/pp_dirichlet_process.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import matplotlib.pyplot
  import tensorflow
  from edward.models import Bernoulli, Beta, DirichletProcess, Exponential, Normal
label_desc: Use image node_id 1 for calling a global function with example usage: dirichlet_process(alpha) and returns: stick_num, tf, unknown,  beta_k