human
Solve the following python programming problem given the following code:
@nodes_or_number(0)
def geographical_threshold_graph(n, theta, alpha=2, dim=2, pos=None, weight=None, metric=None):
assistant
#Here is the Python program you requested.

    """Returns a geographical threshold graph.
    The geographical threshold graph model places `n` nodes uniformly at
    random in a rectangular domain.  Each node `u` is assigned a weight
    :math:`w_u`. Two nodes `u` and `v` are joined by an edge if
    .. math::
    w_u + w_v \ge \theta r^{\alpha}
    where `r` is the distance between `u` and `v`, and :math:`\theta`,
    :math:`\alpha` are parameters.
    Parameters
    n : int or iterable
    Number of nodes or iterable of nodes
    theta: float
    Threshold value
    alpha: float, optional
    Exponent of distance function
    dim : int, optional
    Dimension of graph
    pos : dict
    Node positions as a dictionary of tuples keyed by node.
    weight : dict
    Node weights as a dictionary of numbers keyed by node.
    metric : function
    A metric on vectors of numbers (represented as lists or
    tuples). This must be a function that accepts two lists (or
    tuples) as input and yields a number as output. The function
    must also satisfy the four requirements of a `metric`_.
    Specifically, if *d* is the function and *x*, *y*,
    and *z* are vectors in the graph, then *d* must satisfy
    1. *d*(*x*, *y*) â¥ 0,
    2. *d*(*x*, *y*) = 0 if and only if *x* = *y*,
    3. *d*(*x*, *y*) = *d*(*y*, *x*),
    4. *d*(*x*, *z*) â€ *d*(*x*, *y*) + *d*(*y*, *z*).
    If this argument is not specified, the Euclidean distance metric is
    used.
    .. _metric: https://en.wikipedia.org/wiki/Metric_%28mathematics%29
    Returns
    Graph
    A random geographic threshold graph, undirected and without
    self-loops.
    Each node has a node attribute ``\pos\`` that stores the
    position of that node in Euclidean space as provided by the
    ``pos`` keyword argument or, if ``pos`` was not provided, as
    generated by this function. Similarly, each node has a node
    attribute ``\weight\`` that stores the weight of that node as
    provided or as generated.
    Examples
    Specify an alternate distance metric using the ``metric`` keyword
    argument...."""
    (n_name, nodes) = n
    G = nx.Graph()
    G.add_nodes_from(nodes)
    if (weight is None):
        weight = {v: random.expovariate(1) for v in G}
    if (pos is None):
        pos = {v: [random.random() for i in range(dim)] for v in nodes}
    if (metric is None):
        metric = euclidean
    nx.set_node_attributes(G, weight, 'weight')
    nx.set_node_attributes(G, pos, 'pos')
    def should_join(pair):
        (u, v) = pair
        (u_pos, v_pos) = (pos[u], pos[v])
        (u_weight, v_weight) = (weight[u], weight[v])
        return ((theta * (metric(u_pos, v_pos) ** alpha)) <= (u_weight + v_weight))
    G.add_edges_from(filter(should_join, combinations(G, 2)))
    return G