docstr: Initializes locality-sensitive hashing with FALCONN to find nearest neighbors in training data.
code: def init_lsh(self):
      """
      Initializes locality-sensitive hashing with FALCONN to find nearest neighbors in training data.
      """
      self.query_objects = (
          {}
      )  # contains the object that can be queried to find nearest neighbors at each layer.
      # mean of training data representation per layer (that needs to be substracted before
      # NearestNeighbor).
      self.centers = {}
      for layer in self.layers:
          # Normalize all the lenghts, since we care about the cosine similarity.
          self.train_activations_lsh[layer] /= np.linalg.norm(
              self.train_activations_lsh[layer], axis=1
          ).reshape(-1, 1)
  
          # Center the dataset and the queries: this improves the performance of LSH quite a bit.
          center = np.mean(self.train_activations_lsh[layer], axis=0)
          self.train_activations_lsh[layer] -= center
          self.centers[layer] = center
  
          print("Constructing the NearestNeighbor table")
          self.query_objects[layer] = NearestNeighbor(
              backend=FLAGS.nearest_neighbor_backend,
              dimension=self.train_activations_lsh[layer].shape[1],
              number_bits=self.number_bits,
              neighbors=self.neighbors,
              nb_tables=self.nb_tables,
          )
  
          self.query_objects[layer].add(
              self.train_activations_lsh[layer]
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import copy
  import os
  from bisect import bisect_left
  import matplotlib
  import matplotlib.pyplot
  import numpy
  from six.moves import xrange
  import enum
  import tensorflow
  from cleverhans.attacks import FastGradientMethod
  from cleverhans.loss import CrossEntropy
  from cleverhans.dataset import MNIST
  from cleverhans.model import Model
  from cleverhans.picklable_model import MLP, Conv2D, ReLU, Flatten, Linear, Softmax
  from cleverhans.train import train
  from cleverhans.utils_tf import batch_eval, model_eval
label_desc: Use image node_id 2 for calling the DkNNModel obj's underlying member method code with example usage: obj.init_lsh() without return types