class_docstr: Class to implement highly efficient vectorised look-ups.
  
  We do not utilise looping for that purpose, instead we `smartly` reshape and
  tile arrays. The trade-off is that we are potentially using way more memory
  than we would have if looping is used.
  
  Each class that inherits from this class is supposed to implement a
  particular lookup function for a certain shape.
  
  For example, look-ups for 2D table will be different in the case of 3D.
class_docstr_tok: ["Class","to","implement","highly","efficient","vectorised","look-ups",".","We","do","not","utilise","looping","for","that","purpose",",","instead","we","`","smartly","`","reshape","and","tile","arrays",".","The","trade-off","is","that","we","are","potentially","using","way","more","memory","than","we","would","have","if","looping","is","used",".","Each","class","that","inherits","from","this","class","is","supposed","to","implement","a","particular","lookup","function","for","a","certain","shape",".","For","example",",","look-ups","for","2D","table","will","be","different","in","the","case","of","3D","."]
docstr: Returns indices of closest cluster centroids.
  
  Takes a weight(can be 1D, 2D or ND) and creates tf.int32 array of the
  same shape that will hold indices of cluster centroids clustered arrays
  elements will be pulled from.
  
  In the current setup pulling indices are meant to be created once and
  used everywhere.
  
  Args:
    weight: ND array of weights. For each weight in this array the closest
      cluster centroids is found.
    centroids: Optional list of cluster centroids.
  
  Returns:
    ND array of the same shape as `weight` parameter of the type
    tf.int32. The returned array contain weight lookup indices
docstr_tok: ["Returns","indices","of","closest","cluster","centroids",".","Takes","a","weight","(","can","be","1D",",","2D","or","ND",")","and","creates","tf.int32","array","of","the","same","shape","that","will","hold","indices","of","cluster","centroids","clustered","arrays","elements","will","be","pulled","from",".","In","the","current","setup","pulling","indices","are","meant","to","be","created","once","and","used","everywhere",".","Args",":","weight",":","ND","array","of","weights",".","For","each","weight","in","this","array","the","closest","cluster","centroids","is","found",".","centroids",":","Optional","list","of","cluster","centroids",".","Returns",":","ND","array","of","the","same","shape","as","`","weight","`","parameter","of","the","type","tf.int32",".","The","returned","array","contain","weight","lookup","indices"]
code: def get_pulling_indices(self, weight, centroids=None):
      """Returns indices of closest cluster centroids.
  
      Takes a weight(can be 1D, 2D or ND) and creates tf.int32 array of the
      same shape that will hold indices of cluster centroids clustered arrays
      elements will be pulled from.
  
      In the current setup pulling indices are meant to be created once and
      used everywhere.
  
      Args:
        weight: ND array of weights. For each weight in this array the closest
          cluster centroids is found.
        centroids: Optional list of cluster centroids.
  
      Returns:
        ND array of the same shape as `weight` parameter of the type
        tf.int32. The returned array contain weight lookup indices
      """
  
      cluster_centroids = (
          centroids
          if centroids is not None
          else (self.cluster_centroids)
      )
  
      # We find the nearest cluster centroids and store them so that ops can build
      # their kernels upon it.
      pulling_indices = tf.argmin(
          tf.abs(tf.expand_dims(weight, axis=-1) - cluster_centroids),
          axis=-1,
      )
  
      return pulling_indices
  
file_path: model-optimization/tensorflow_model_optimization/python/core/clustering/keras/clustering_algorithm.py
imports: import abc
  import six
  import tensorflow
  from tensorflow_model_optimization.python.core.clustering.keras.cluster_config import GradientAggregation
label_desc: Use image node_id 4 for calling the ClusteringAlgorithm obj's underlying member method code with example usage: obj.get_pulling_indices(weight, centroids) and returns: pulling_indices