import torch
from typing import Dict


def _get_attribute_name(node: torch._C.Node) -> Dict[str, str]:
    """
    Retrieve the attributes associated with the graph node
    :param node: trace graph node
    :return: a dictionary of attributes associated with the node
    """
    attributes = {}
    # node description has pseudo-code of the form  '... torch_mangle_2.Module = prim::GetAttr[name="fc"](%self.1)'
    # for the above example attributeNames() iterator should return a string 'name'
    node_desc = str(node)
    for attribute_name in node.attributeNames():
        pattern = attribute_name + '="'
        if pattern in node_desc:
            attributes[attribute_name] = node_desc.split(pattern)[1].split('"')[0]
    return attributes