code: def thresholded_random_geometric_graph(
      n,
      radius,
      theta,
      dim=2,
      pos=None,
      weight=None,
      p=2,
      seed=None,
      *,
      pos_name="pos",
      weight_name="weight",
  ):
      r"""Returns a thresholded random geometric graph in the unit cube.
  
      The thresholded random geometric graph [1] model places `n` nodes
      uniformly at random in the unit cube of dimensions `dim`. Each node
      `u` is assigned a weight :math:`w_u`. Two nodes `u` and `v` are
      joined by an edge if they are within the maximum connection distance,
      `radius` computed by the `p`-Minkowski distance and the summation of
      weights :math:`w_u` + :math:`w_v` is greater than or equal
      to the threshold parameter `theta`.
  
      Edges within `radius` of each other are determined using a KDTree when
      SciPy is available. This reduces the time complexity from :math:`O(n^2)`
      to :math:`O(n)`.
  
      Parameters
      ----------
      n : int or iterable
          Number of nodes or iterable of nodes
      radius: float
          Distance threshold value
      theta: float
          Threshold value
      dim : int, optional
          Dimension of graph
      pos : dict, optional
          A dictionary keyed by node with node positions as values.
      weight : dict, optional
          Node weights as a dictionary of numbers keyed by node.
      p : float, optional (default 2)
          Which Minkowski distance metric to use.  `p` has to meet the condition
          ``1 <= p <= infinity``.
  
          If this argument is not specified, the :math:`L^2` metric
          (the Euclidean distance metric), p = 2 is used.
  
          This should not be confused with the `p` of an Erdős-Rényi random
          graph, which represents probability.
      seed : integer, random_state, or None (default)
          Indicator of random number generation state.
          See :ref:`Randomness<randomness>`.
      pos_name : string, default="pos"
          The name of the node attribute which represents the position
          in 2D coordinates of the node in the returned graph.
      weight_name : string, default="weight"
          The name of the node attribute which represents the weight
          of the node in the returned graph.
  
      Returns
      -------
      Graph
          A thresholded random geographic 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 nodethre
          attribute ``'weight'`` that stores the weight of that node as
          provided or as generated.
  
      Examples
      --------
      Default Graph:
  
      G = nx.thresholded_random_geometric_graph(50, 0.2, 0.1)
  
      Custom Graph:
  
      Create a thresholded random geometric graph on 50 uniformly distributed
      nodes where nodes are joined by an edge if their sum weights drawn from
      a exponential distribution with rate = 5 are >= theta = 0.1 and their
      Euclidean distance is at most 0.2.
  
      Notes
      -----
      This uses a *k*-d tree to build the graph.
  
      The `pos` keyword argument can be used to specify node positions so you
      can create an arbitrary distribution and domain for positions.
  
      For example, to use a 2D Gaussian distribution of node positions with mean
      (0, 0) and standard deviation 2
  
      If weights are not specified they are assigned to nodes by drawing randomly
      from the exponential distribution with rate parameter :math:`\lambda=1`.
      To specify weights from a different distribution, use the `weight` keyword
      argument::
  
      ::
  
      >>> import random
      >>> import math
      >>> n = 50
      >>> pos = {i: (random.gauss(0, 2), random.gauss(0, 2)) for i in range(n)}
      >>> w = {i: random.expovariate(5.0) for i in range(n)}
      >>> G = nx.thresholded_random_geometric_graph(n, 0.2, 0.1, 2, pos, w)
  
      References
      ----------
      .. [1] http://cole-maclean.github.io/blog/files/thesis.pdf
  
      """
      G = nx.empty_graph(n)
      G.name = f"thresholded_random_geometric_graph({n}, {radius}, {theta}, {dim})"
      # If no weights are provided, choose them from an exponential
      # distribution.
      if weight is None:
          weight = {v: seed.expovariate(1) for v in G}
      # If no positions are provided, choose uniformly random vectors in
      # Euclidean space of the specified dimension.
      if pos is None:
          pos = {v: [seed.random() for i in range(dim)] for v in G}
      # If no distance metric is provided, use Euclidean distance.
      nx.set_node_attributes(G, weight, weight_name)
      nx.set_node_attributes(G, pos, pos_name)
  
      edges = (
          (u, v)
          for u, v in _geometric_edges(G, radius, p, pos_name)
          if weight[u] + weight[v] >= theta
      )
      G.add_edges_from(edges)
      return G
  
file_path: networkx/networkx/generators/geometric.py
imports: import math
  from bisect import bisect_left
  from itertools import accumulate, combinations, product
  import networkx
  from networkx.utils import py_random_state
label_desc: Use image node_id 8 for calling a global function with example usage: thresholded_random_geometric_graph(n, radius, theta, dim, pos, weight, p, seed) and returns: G