class_docstr: Implements locality-sensitive hashing for low-dimensional euclidean space.
  
  
  Allows to efficiently find neighbours of a point. Provides 2 guarantees:
  
  -   Difference between coordinates of points not returned by :meth:`nearby`
      and input point is larger than ``radius``.
  -   Difference between coordinates of points returned by :meth:`nearby` and
      input point is smaller than 2 ``radius``.
  
  Example:
  
      >>> radius = 1
      >>> lsh = LSH(radius)
      >>> a = torch.tensor([-0.51, -0.51]) # hash(a)=(-1,-1)
      >>> b = torch.tensor([-0.49, -0.49]) # hash(a)=(0,0)
      >>> c = torch.tensor([1.0, 1.0]) # hash(b)=(1,1)
      >>> lsh.add('a', a)
      >>> lsh.add('b', b)
      >>> lsh.add('c', c)
      >>> # even though c is within 2radius of a
      >>> lsh.nearby('a') # doctest: +SKIP
      {'b'}
      >>> lsh.nearby('b') # doctest: +SKIP
      {'a', 'c'}
      >>> lsh.remove('b')
      >>> lsh.nearby('a') # doctest: +SKIP
      set()
  
  
  :param float radius: Scaling parameter used in hash function. Determines the size of the neighbourhood.
docstr: Returns a set of keys which are neighbours of the point identified by ``key``.
  
  
  Two points are nearby if difference of each element of their hashes is smaller than 2. In euclidean space, this
  corresponds to all points :math:`\mathbf{p}` where :math:`|\mathbf{p}_k-(\mathbf{p_{key}})_k|<r`,
  and some points (all points not guaranteed) where :math:`|\mathbf{p}_k-(\mathbf{p_{key}})_k|<2r`.
  
  
  :param key: key used to identify input point.
  :return: a set of keys identifying neighbours of the input point.
  :rtype: set
docstr_tok: ["Returns","a","set","of","keys","which","are","neighbours","of","the","point","identified","by","``","key","``",".","Two","points","are","nearby","if","difference","of","each","element","of","their","hashes","is","smaller","than","2",".","In","euclidean","space",",","this","corresponds","to","all","points",":","math",":","`","\\mathbf","{","p","}","`","where",":","math",":","`","|\\mathbf","{","p","}","_k-","(","\\mathbf","{","p_","{","key","}","}",")","_k|","<","r","`",",","and","some","points","(","all","points","not","guaranteed",")","where",":","math",":","`","|\\mathbf","{","p","}","_k-","(","\\mathbf","{","p_","{","key","}","}",")","_k|","<","2r","`",".",":","param","key",":","key","used","to","identify","input","point",".",":","return",":","a","set","of","keys","identifying","neighbours","of","the","input","point",".",":","rtype",":","set"]
code: def nearby(self, key):
      r"""
      Returns a set of keys which are neighbours of the point identified by ``key``.
  
  
      Two points are nearby if difference of each element of their hashes is smaller than 2. In euclidean space, this
      corresponds to all points :math:`\mathbf{p}` where :math:`|\mathbf{p}_k-(\mathbf{p_{key}})_k|<r`,
      and some points (all points not guaranteed) where :math:`|\mathbf{p}_k-(\mathbf{p_{key}})_k|<2r`.
  
  
      :param key: key used to identify input point.
      :return: a set of keys identifying neighbours of the input point.
      :rtype: set
      """
      _hash = self._key_to_hash[key]
      result = set()
      for nearby_hash in itertools.product(
          *[[i - 1, i, i + 1] for i in _hash]
      ):
          result |= self._hash_to_key[nearby_hash]
      result.remove(key)
      return result
  
file_path: pyro/pyro/contrib/tracking/hashing.py
imports: import heapq
  import itertools
  from collections import defaultdict
  from numbers import Number
  import torch
label_desc: Use image node_id 5 for calling the LSH obj's underlying member method code with example usage: obj.nearby(key) and returns: result