def sample(prediction):
 p = np.zeros(shape=[1, vocabulary_size], dtype=np.float)
 p[(0, sample_distribution(prediction[0]))] = 1.0
 return p

def sample ( prediction ) : p = np . zeros ( shape = [ 1 , vocabulary_size ] , dtype = np . float ) p [ ( 0 , sample_distribution ( prediction [ 0 ] ) ) ] = 1.0 return p
sample an index from a probability array .