human
Complete the below
def AddCrossEntropy(batch_size, n):

    ''''Adds a cross entropy cost function.'
    '''
 ... Write me a the Python program you requested?
assistant
#Here is the Python program you requested.
    cross_entropies = []
    def _Pass():
        return tf.constant(0, dtype=tf.float32, shape=[1])
    for beam_id in range(batch_size):
        beam_gold_slot = tf.reshape(tf.strided_slice(n['gold_slot'], [beam_id], [(beam_id + 1)]), [1])
        def _ComputeCrossEntropy():
            'Adds    ops    to    compute    cross    entropy    of    the    gold    path    in    a    beam.'
            idx = tf.cast(tf.reshape(tf.where(tf.equal(n['beam_ids'], beam_id)), [(-1)]), tf.int32)
            beam_scores = tf.reshape(tf.gather(n['all_path_scores'], idx), [1, (-1)])
            num = tf.shape(idx)
            return tf.nn.softmax_cross_entropy_with_logits(labels=tf.expand_dims(tf.sparse_to_dense(beam_gold_slot, num, [1.0], 0.0), 0), logits=beam_scores)
        cross_entropies.append(cf.cond((beam_gold_slot[0] >= 0), _ComputeCrossEntropy, _Pass))
    return {'cross_entropy': tf.div(tf.add_n(cross_entropies), batch_size)}