def has_feed_operators(block, feed_targets, feed_holder_name):
    ' Check whether the block already has feed operators.\n\n    Return false if the block does not have any feed operators.\n    If some feed operators have been prepended to the block, check that\n    the info contained in these feed operators matches the feed_targets\n    and feed_holder_name. Raise exception when any mismatch is found.\n    Return true when the block has feed operators with matching info.\n\n    Args:\n        block: a block instance (typically global block of a program)\n        feed_targets: a dictionary of {feed_target_name: feed_target_data}\n        feed_holder_name: the name of the variable that holds the data of\n            all feed targets. The type of this feed_holder variable is\n            FEED_MINIBATCH, which is essentially vector<LoDTensor>.\n\n    Returns:\n        A boolean value that indicates whether a block has feed operators\n        that match the info contained in feed_targets and feed_holder_name.\n    '
    feed_count = 0
    for op in block.ops:
        if (op.desc.type() == 'feed'):
            feed_count += 1
            assert (op.desc.input('X')[0] == feed_holder_name)
            feed_target_name = op.desc.output('Out')[0]
            if (feed_target_name not in feed_targets):
                raise Exception("'feed_targets' does not have {} variable".format(feed_target_name))
        else:
            break
    if ((feed_count > 0) and (feed_count != len(feed_targets))):
        raise Exception("Feed operators in program desc do not match 'feed_targets'")
    return (feed_count > 0)
Check whether the block already has feed operators.

Return false if the block does not have any feed operators.
If some feed operators have been prepended to the block, check that
the info contained in these feed operators matches the feed_targets
and feed_holder_name. Raise exception when any mismatch is found.
Return true when the block has feed operators with matching info.

Args:
    block: a block instance (typically global block of a program)
    feed_targets: a dictionary of {feed_target_name: feed_target_data}
    feed_holder_name: the name of the variable that holds the data of
        all feed targets. The type of this feed_holder variable is
        FEED_MINIBATCH, which is essentially vector<LoDTensor>.

Returns:
    A boolean value that indicates whether a block has feed operators
    that match the info contained in feed_targets and feed_holder_name.
def has_feed_operators(block, feed_targets, feed_holder_name):
    ' Check whether the block already has feed operators.\n\n    Return false if the block does not have any feed operators.\n    If some feed operators have been prepended to the block, check that\n    the info contained in these feed operators matches the feed_targets\n    and feed_holder_name. Raise exception when any mismatch is found.\n    Return true when the block has feed operators with matching info.\n\n    Args:\n        block: a block instance (typically global block of a program)\n        feed_targets: a dictionary of {feed_target_name: feed_target_data}\n        feed_holder_name: the name of the variable that holds the data of\n            all feed targets. The type of this feed_holder variable is\n            FEED_MINIBATCH, which is essentially vector<LoDTensor>.\n\n    Returns:\n        A boolean value that indicates whether a block has feed operators\n        that match the info contained in feed_targets and feed_holder_name.\n    '
    feed_count = 0
    for op in block.ops:
        if (op.desc.type() == 'feed'):
            feed_count += 1
            assert (op.desc.input('X')[0] == feed_holder_name)
            feed_target_name = op.desc.output('Out')[0]
            if (feed_target_name not in feed_targets):
                raise Exception("'feed_targets' does not have {} variable".format(feed_target_name))
        else:
            break
    if ((feed_count > 0) and (feed_count != len(feed_targets))):
        raise Exception("Feed operators in program desc do not match 'feed_targets'")
    return (feed_count > 0)