class_docstr: Computes the similarity graph from a set of (dense) embeddings.
docstr: Generates edges among pairs of the given `embeddings`.
  
  This function considers related pairs of nodes in `embeddings`,
  computes the cosine similarity between all such pairs, and yields any edge
  for which the cosine similarity is at least `self.similarity_threshold`.
  
  Args:
    embeddings: A `dict`: node_id -> embedding.
  
  Yields:
    A tuple (source, target, weight) denoting a (directed) edge from 'source'
    to 'target' with the given 'weight'.
docstr_tok: ["Generates","edges","among","pairs","of","the","given","`","embeddings","`",".","This","function","considers","related","pairs","of","nodes","in","`","embeddings","`",",","computes","the","cosine","similarity","between","all","such","pairs",",","and","yields","any","edge","for","which","the","cosine","similarity","is","at","least","`","self.similarity_threshold","`",".","Args",":","embeddings",":","A","`","dict","`",":","node_id","-",">","embedding",".","Yields",":","A","tuple","(","source",",","target",",","weight",")","denoting","a","(","directed",")","edge","from","'source'","to","'target","'","with","the","given","'weight","'","."]
code: def _generate_edges(self, embeddings):
      """Generates edges among pairs of the given `embeddings`.
  
      This function considers related pairs of nodes in `embeddings`,
      computes the cosine similarity between all such pairs, and yields any edge
      for which the cosine similarity is at least `self.similarity_threshold`.
  
      Args:
        embeddings: A `dict`: node_id -> embedding.
  
      Yields:
        A tuple (source, target, weight) denoting a (directed) edge from 'source'
        to 'target' with the given 'weight'.
      """
      # If lsh_splits < 1, we ignore lsh_rounds and always perform 1 round, since
      # performing multiple rounds in the case of no splits does not help.
      rounds = (
          self.config.lsh_rounds if self.config.lsh_splits > 0 else 1
      )
      for lsh_round in range(rounds):
          start_time = time.time()
          edge_cnt = 0
          bucket_map = self._generate_lsh_buckets(embeddings)
          logging_prefix = "LSH bucketing round {}".format(lsh_round)
          logging.info(
              "%s: created %d bucket(s) in %.2f seconds.",
              logging_prefix,
              len(bucket_map),
              time.time() - start_time,
          )
          for bucket in bucket_map.values():
              for edge in self._generate_edges_for_bucket(
                  bucket, embeddings
              ):
                  edge_cnt += 1
                  if (edge_cnt % 1000000) == 0:
                      logging.info(
                          "%s: generated %d new bi-directional edges in %.2f seconds....",
                          logging_prefix,
                          edge_cnt,
                          time.time() - start_time,
                      )
                  yield edge
          logging.info(
              "%s completed: generated %d new bi-directional edges in %.2f seconds.",
              logging_prefix,
              edge_cnt,
              time.time() - start_time,
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import itertools
  import time
  from absl import app
  from absl import flags
  from absl import logging
  import neural_structured_learning.configs
  import numpy
  import six
  import tensorflow
label_desc: Use image node_id 6 for calling the GraphBuilder obj's underlying member method code with example usage: obj._generate_edges(embeddings) without return types