def _top_k(operand: TfVal, k: int) -> Tuple[(TfVal, TfVal)]:

    def promote_tf_dtype(tf_dtype):
        if (tf_dtype in [tf.bool, tf.uint8, tf.uint16]):
            return tf.uint32
        if (tf_dtype in [tf.int8, tf.int16]):
            return tf.int32
        if (tf_dtype is tf.float16):
            return tf.float32
        return None
    conversion_dtype = promote_tf_dtype(operand.dtype)
    if conversion_dtype:
        (values, indices) = tf.math.top_k(tf.dtypes.cast(operand, conversion_dtype), k=k, sorted=True)
        return (tf.dtypes.cast(values, operand.dtype), indices)
    else:
        return tf.math.top_k(operand, k=k, sorted=True)
def _top_k(operand: TfVal, k: int) -> Tuple[(TfVal, TfVal)]:

    def promote_tf_dtype(tf_dtype):
        if (tf_dtype in [tf.bool, tf.uint8, tf.uint16]):
            return tf.uint32
        if (tf_dtype in [tf.int8, tf.int16]):
            return tf.int32
        if (tf_dtype is tf.float16):
            return tf.float32
        return None
    conversion_dtype = promote_tf_dtype(operand.dtype)
    if conversion_dtype:
        (values, indices) = tf.math.top_k(tf.dtypes.cast(operand, conversion_dtype), k=k, sorted=True)
        return (tf.dtypes.cast(values, operand.dtype), indices)
    else:
        return tf.math.top_k(operand, k=k, sorted=True)