code: def get_weights(i, j, labels_mask):
      """Return the weights to assign each i,j point
  
      Assign each pixel in the labels mask to the nearest i,j and return
      the number of pixels assigned to each i,j
      """
      #
      # Create a mapping of chosen points to their index in the i,j array
      #
      total_skel = np.zeros(labels_mask.shape, int)
      total_skel[i, j] = np.arange(1, len(i) + 1)
      #
      # Compute the distance from each chosen point to all others in image,
      # return the nearest point.
      #
      ii, jj = scipy.ndimage.distance_transform_edt(
          total_skel == 0, return_indices=True, return_distances=False
      )
      #
      # Filter out all unmasked points
      #
      ii, jj = [x[labels_mask] for x in (ii, jj)]
      if len(ii) == 0:
          return np.zeros(0, np.int32)
      #
      # Use total_skel to look up the indices of the chosen points and
      # bincount the indices.
      #
      result = np.zeros(len(i), np.int32)
      bc = np.bincount(total_skel[ii, jj])[1:]
      result[: len(bc)] = bc
      return result
  
imports: import numpy
  import scipy
  import centrosome
  import centrosome.cpmorphology
  import centrosome.filter
  import centrosome.propagate
  import centrosome.fastemd
  from sklearn.cluster import KMeans
  from cellprofiler_library.opts import measureimageoverlap
  from cellprofiler_library.functions.segmentation import convert_labels_to_ijv
  from cellprofiler_library.functions.segmentation import indices_from_ijv
  from cellprofiler_library.functions.segmentation import count_from_ijv
  from cellprofiler_library.functions.segmentation import areas_from_ijv
  from cellprofiler_library.functions.segmentation import cast_labels_to_label_set
label_desc: Use image node_id 7 for calling a global function with example usage: get_weights(i, j, labels_mask) and returns: result, np