(logits, num_samples_var)
return ret
Multinomial python function definition
        Input:
            input: list of [logits_array, num_samples_int]
Multinomial python function definition
        Input:
            input: list of [logits_array, num_samples_int]
Multinomial python function definition Input : input : list of [ logits_array num_samples_int ]
def py_func_multinomial(logits, num_samples_var):
    """
        Multinomial python function definition
        Input:
            input: list of [logits_array, num_samples_int]
    """
    def generate(x, prob_array):
        """
            Sample multinomial
        """
        sample = np.random.multinomial(1, prob_array)
        ret = np.argmax(sample)
        return ret

    num_samples = int(np.array(num_samples_var)[0])
    logits_array = np.array(logits)
    if len(logits_array.shape) != 2:
        raise Exception("Shape must be rank 2 but is rank {} \
                        for 'multinomial/Multinomial' (op: 'Multinomial') \
                        with input shapes:{}".format(len(logits_array.shape),
                                                     logits_array.shape))
    ret = np.array([])
    for logits in logits_array:
        prob = softmax(logits)
        func = functools.partial(generate, prob_array=prob)
        sample = np.zeros(num_samples)
        sample = np.array(list(map(func, sample)))
        ret = np.append(ret, sample)
    ret = ret.reshape(-1, num_samples).astype("int32")
    return ret
def py_func_multinomial ( logits , num_samples_var ) : def generate ( x , prob_array ) : """
            Sample multinomial
        """ sample = np . random . multinomial ( 1 , prob_array ) ret = np . argmax ( sample ) return ret num_samples = int ( np . array ( num_samples_var ) [ 0 ] ) logits_array = np . array ( logits ) if len ( logits_array . shape ) != 2 : raise Exception ( "Shape must be rank 2 but is rank {} \
                        for 'multinomial/Multinomial' (op: 'Multinomial') \
                        with input shapes:{}" . format ( len ( logits_array . shape ) , logits_array . shape ) ) ret = np . array ( [ ] ) for logits in logits_array : prob = softmax ( logits ) func = functools . partial ( generate , prob_array = prob ) sample = np . zeros ( num_samples ) sample = np . array ( list ( map ( func , sample ) ) ) ret = np . append ( ret , sample ) ret = ret . reshape ( - 1 , num_samples ) . astype ( "int32" ) return ret