def _convert_node_attr_types(G: nx.MultiDiGraph, dtypes: dict[str, Any]) -> nx.MultiDiGraph:
    """
    Convert graph nodes' attributes using a dict of data types.

    Parameters
    ----------
    G
        Graph to convert the node attributes of.
    dtypes
        Dict of node attribute names:types.

    Returns
    -------
    G
        The graph with its nodes' attributes' types converted.
    """
    for _, data in G.nodes(data=True):
        # first, eval stringified lists, dicts, or sets to convert them to objects
        # lists, dicts, or sets would be custom attribute types added by a user
        for attr, value in data.items():
            if (value.startswith("[") and value.endswith("]")) or (
                value.startswith("{") and value.endswith("}")
            ):
                with contextlib.suppress(SyntaxError, ValueError):
                    data[attr] = ast.literal_eval(value)

        for attr in data.keys() & dtypes.keys():
            data[attr] = dtypes[attr](data[attr])
    return G

    Convert graph nodes' attributes using a dict of data types.

    Parameters
    ----------
    G
        Graph to convert the node attributes of.
    dtypes
        Dict of node attribute names:types.

    Returns
    -------
    G
        The graph with its nodes' attributes' types converted.
    
osmnx/io.py