TrainingExtensions/tensorflow/src/python/aimet_tensorflow/keras/utils/common.py
def module_to_name_map(cur_layer: (tf.keras.Model, tf.keras.layers.Layer)) \
        -> typing.Dict[tf.keras.layers.Layer, typing.Tuple[tf.keras.Model, str]]:
    """
    To find a variable name and parent reference of one module.

    :param cur_layer: model to obtain module_to_name_map
    :return: dictionary includes module_ref as a key, parent_ref and module_name as value
    """

    ref_name = {}
    # pylint: disable=protected-access
    for inner_layer in cur_layer._layers:
        if inner_layer.submodules:
            ref_name.update(module_to_name_map(inner_layer))
        else:
            for key, element in vars(cur_layer).items():
                if isinstance(element, tf.keras.layers.Layer) and element == inner_layer:
                    ref_name[element] = (cur_layer, key)

    return ref_name

    To find a variable name and parent reference of one module.

    :param cur_layer: model to obtain module_to_name_map
    :return: dictionary includes module_ref as a key, parent_ref and module_name as value
    
To find a variable name and parent reference of one module.
To find a variable name and parent reference of one module .
def module_to_name_map(cur_layer: (tf.keras.Model, tf.keras.layers.Layer)) \
        -> typing.Dict[tf.keras.layers.Layer, typing.Tuple[tf.keras.Model, str]]:
    ref_name = {}
    for inner_layer in cur_layer._layers:
        if inner_layer.submodules:
            ref_name.update(module_to_name_map(inner_layer))
        else:
            for key, element in vars(cur_layer).items():
                if isinstance(element, tf.keras.layers.Layer) and element == inner_layer:
                    ref_name[element] = (cur_layer, key)
    return ref_name
def module_to_name_map ( cur_layer : ( tf . keras . Model , tf . keras . layers . Layer ) ) -> typing . Dict [ tf . keras . layers . Layer , typing . Tuple [ tf . keras . Model , str ] ] : ref_name = { } for inner_layer in cur_layer . _layers : if inner_layer . submodules : ref_name . update ( module_to_name_map ( inner_layer ) ) else : for key , element in vars ( cur_layer ) . items ( ) : if isinstance ( element , tf . keras . layers . Layer ) and element == inner_layer : ref_name [ element ] = ( cur_layer , key ) return ref_name
To find a variable name and parent reference of one module.
To find a variable name and parent reference of one module .
"""
    To find a variable name and parent reference of one module.

    :param cur_layer: model to obtain module_to_name_map
    :return: dictionary includes module_ref as a key, parent_ref and module_name as value
    """ # pylint: disable=protected-access
dictionary includes module_ref as a key, parent_ref and module_name as value
dictionary includes module_ref as a key parent_ref and module_name as value
cur_layer
(tf.keras.Model, tf.keras.layers.Layer)
model to obtain module_to_name_map
model to obtain module_to_name_map