TrainingExtensions/tensorflow/src/python/aimet_tensorflow/keras/utils/common.py
def create_node_to_layer_map(cur_layer: (tf.keras.Model, tf.keras.layers.Layer)) -> typing.Dict:
    """
    To find the input layers and output layer of one node.

    :param cur_layer: model to obtain node_to_layer_map
    :return: return dictionary includes node_ref as a key, in_layers and out_layer as value
    """

    node_layer_map = {}
    # pylint: disable=protected-access
    for inner_layer in cur_layer._layers:
        for out_node in inner_layer.outbound_nodes:
            if out_node in node_layer_map:
                node_layer_map[out_node][0].append(inner_layer)
            else:
                node_layer_map[out_node] = [[inner_layer], None]
        for in_node in inner_layer.inbound_nodes:
            if in_node in node_layer_map:
                node_layer_map[in_node][1] = inner_layer
            else:
                node_layer_map[in_node] = [None, inner_layer]
        if inner_layer.submodules:
            im_node_layer_map, im_node_input, im_nodes_after_input_layer = \
                _submodule_handler_node_to_layer_map(inner_layer, node_layer_map)
            if len(im_nodes_after_input_layer) == 1:
                del im_node_layer_map[im_nodes_after_input_layer[0]]
            del im_node_layer_map[im_node_input]

            node_layer_map.update(im_node_layer_map)

    return node_layer_map

    To find the input layers and output layer of one node.

    :param cur_layer: model to obtain node_to_layer_map
    :return: return dictionary includes node_ref as a key, in_layers and out_layer as value
    
To find the input layers and output layer of one node.
To find the input layers and output layer of one node .
def create_node_to_layer_map(cur_layer: (tf.keras.Model, tf.keras.layers.Layer)) -> typing.Dict:
    node_layer_map = {}
    for inner_layer in cur_layer._layers:
        for out_node in inner_layer.outbound_nodes:
            if out_node in node_layer_map:
                node_layer_map[out_node][0].append(inner_layer)
            else:
                node_layer_map[out_node] = [[inner_layer], None]
        for in_node in inner_layer.inbound_nodes:
            if in_node in node_layer_map:
                node_layer_map[in_node][1] = inner_layer
            else:
                node_layer_map[in_node] = [None, inner_layer]
        if inner_layer.submodules:
            im_node_layer_map, im_node_input, im_nodes_after_input_layer = \
                _submodule_handler_node_to_layer_map(inner_layer, node_layer_map)
            if len(im_nodes_after_input_layer) == 1:
                del im_node_layer_map[im_nodes_after_input_layer[0]]
            del im_node_layer_map[im_node_input]
            node_layer_map.update(im_node_layer_map)
    return node_layer_map
def create_node_to_layer_map ( cur_layer : ( tf . keras . Model , tf . keras . layers . Layer ) ) -> typing . Dict : node_layer_map = { } for inner_layer in cur_layer . _layers : for out_node in inner_layer . outbound_nodes : if out_node in node_layer_map : node_layer_map [ out_node ] [ 0 ] . append ( inner_layer ) else : node_layer_map [ out_node ] = [ [ inner_layer ] , None ] for in_node in inner_layer . inbound_nodes : if in_node in node_layer_map : node_layer_map [ in_node ] [ 1 ] = inner_layer else : node_layer_map [ in_node ] = [ None , inner_layer ] if inner_layer . submodules : im_node_layer_map , im_node_input , im_nodes_after_input_layer = _submodule_handler_node_to_layer_map ( inner_layer , node_layer_map ) if len ( im_nodes_after_input_layer ) == 1 : del im_node_layer_map [ im_nodes_after_input_layer [ 0 ] ] del im_node_layer_map [ im_node_input ] node_layer_map . update ( im_node_layer_map ) return node_layer_map
To find the input layers and output layer of one node.
To find the input layers and output layer of one node .
"""
    To find the input layers and output layer of one node.

    :param cur_layer: model to obtain node_to_layer_map
    :return: return dictionary includes node_ref as a key, in_layers and out_layer as value
    """ # pylint: disable=protected-access
return dictionary includes node_ref as a key, in_layers and out_layer as value
return dictionary includes node_ref as a key in_layers and out_layer as value
cur_layer
(tf.keras.Model, tf.keras.layers.Layer)
model to obtain node_to_layer_map
model to obtain node_to_layer_map