class_docstr: Computes the similarity graph from a set of (dense) embeddings.
docstr: Buckets the given `embeddings` according to `config.lsh_splits`.
  
  The embeddings can be bucketed into a total of at most `2^n` different
  buckets, where `n` is given by the value of `config.lsh_splits`. If `n` is
  not positive, then all of the given `embeddings` keys will be bucketed into
  bucket 0.
  
  Args:
    embeddings: A `dict`: node_id -> embedding.
  
  Returns:
    A dictionary mapping bucket IDs to sets of embedding IDs in each bucket.
    The bucket IDs are integers in the half-open interval `[0, 2^n)`, where
    `n = config.lsh_splits`.
docstr_tok: ["Buckets","the","given","`","embeddings","`","according","to","`","config.lsh_splits","`",".","The","embeddings","can","be","bucketed","into","a","total","of","at","most","`","2^n","`","different","buckets",",","where","`","n","`","is","given","by","the","value","of","`","config.lsh_splits","`",".","If","`","n","`","is","not","positive",",","then","all","of","the","given","`","embeddings","`","keys","will","be","bucketed","into","bucket","0",".","Args",":","embeddings",":","A","`","dict","`",":","node_id","-",">","embedding",".","Returns",":","A","dictionary","mapping","bucket","IDs","to","sets","of","embedding","IDs","in","each","bucket",".","The","bucket","IDs","are","integers","in","the","half-open","interval","`","[","0",",","2^n",")","`",",","where","`","n","=","config.lsh_splits","`","."]
code: def _generate_lsh_buckets(self, embeddings):
      """Buckets the given `embeddings` according to `config.lsh_splits`.
  
      The embeddings can be bucketed into a total of at most `2^n` different
      buckets, where `n` is given by the value of `config.lsh_splits`. If `n` is
      not positive, then all of the given `embeddings` keys will be bucketed into
      bucket 0.
  
      Args:
        embeddings: A `dict`: node_id -> embedding.
  
      Returns:
        A dictionary mapping bucket IDs to sets of embedding IDs in each bucket.
        The bucket IDs are integers in the half-open interval `[0, 2^n)`, where
        `n = config.lsh_splits`.
      """
      if self.config.lsh_splits <= 0:
          return {0: set(embeddings.keys())}
  
      # Generate a random matrix of values in the range [-1.0, 1.0] to use
      # to create the LSH buckets.
      num_dims = next(iter(embeddings.values())).size
      lsh_matrix = (
          np.random.rand(self.config.lsh_splits, num_dims) * 2 - 1
      )
  
      # Add each embedding to its appropriate bucket
      bucket_map = {}
      for key, embedding in six.iteritems(embeddings):
          s = bucket_map.setdefault(
              self._bucket(lsh_matrix, embedding), set()
          )
          s.add(key)
      return bucket_map
  
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 4 for calling the GraphBuilder obj's underlying member method code with example usage: obj._generate_lsh_buckets(embeddings) and returns: bucket_map, dict