def METHOD_NAME(graph_provider, roi):
    """A static method to convert a daisy graph into a gunpowder graph.
    Only includes edges if both endpoints are within the roi.
    Arguments:
        graph_provider (:class:`daisy.SharedGraphProvider`)
            A daisy graph provider to read the graph from
        roi (:class:`Roi`):
            The roi in which to read the graph
    Returns:
        An instance of :class:`Graph` containing the nodes and edges read
        from the daisy graph provider in the given roi.
    """
    logger.debug("Creating gunpowder graph from daisy graph provider")
    daisy_graph = graph_provider[roi]
    logger.debug("%d nodes found in roi %s", len(daisy_graph), roi)
    spec = GraphSpec(roi=roi, directed=daisy_graph.is_directed())
    dangling_nodes = []
    for node, data in daisy_graph.nodes(data=True):
        position_attribute = graph_provider.position_attribute
        if type(position_attribute) == list:
            if position_attribute[0] not in data:
                dangling_nodes.append(node)
                continue
            location = np.array(
                [data[attr] for attr in position_attribute], dtype=np.float32
            )
        else:
            if position_attribute not in data:
                dangling_nodes.append(node)
                continue
            location = np.array(data[position_attribute], dtype=np.float32)
        data["location"] = location
        data["id"] = node
    logger.debug("Dangling nodes: %s", dangling_nodes)
    for n in dangling_nodes:
        daisy_graph.remove_node(n)
    if daisy_graph.is_directed():
        pure_nx_graph = nx.DiGraph()
    else:
        pure_nx_graph = nx.Graph()
    pure_nx_graph.update(daisy_graph)
    return Graph.from_nx_graph(pure_nx_graph, spec)