class_docstr: Matcher based on highest value.
  
  This class computes matches from a similarity matrix. Each column is matched
  to a single row.
  
  To support object detection target assignment this class enables setting both
  matched_threshold (upper threshold) and unmatched_threshold (lower thresholds)
  defining three categories of similarity which define whether examples are
  positive, negative, or ignored:
  (1) similarity >= matched_threshold: Highest similarity. Matched/Positive!
  (2) matched_threshold > similarity >= unmatched_threshold: Medium similarity.
          Depending on negatives_lower_than_unmatched, this is either
          Unmatched/Negative OR Ignore.
  (3) unmatched_threshold > similarity: Lowest similarity. Depending on flag
          negatives_lower_than_unmatched, either Unmatched/Negative OR Ignore.
  For ignored matches this class sets the values in the Match object to -2.
docstr: Tries to match each column of the similarity matrix to a row.
  
  Args:
    similarity_matrix: tensor of shape [N, M] representing any similarity
      metric.
  
  Returns:
    Match object with corresponding matches for each of M columns.
docstr_tok: ["Tries","to","match","each","column","of","the","similarity","matrix","to","a","row",".","Args",":","similarity_matrix",":","tensor","of","shape","[","N",",","M","]","representing","any","similarity","metric",".","Returns",":","Match","object","with","corresponding","matches","for","each","of","M","columns","."]
code: def _match(self, similarity_matrix):
      """Tries to match each column of the similarity matrix to a row.
  
      Args:
        similarity_matrix: tensor of shape [N, M] representing any similarity
          metric.
  
      Returns:
        Match object with corresponding matches for each of M columns.
      """
  
      def _match_when_rows_are_empty():
          """Performs matching when the rows of similarity matrix are empty.
  
          When the rows are empty, all detections are false positives. So we return
          a tensor of -1's to indicate that the columns do not match to any rows.
  
          Returns:
            matches:  int32 tensor indicating the row each column matches to.
          """
          similarity_matrix_shape = (
              shape_utils.combined_static_and_dynamic_shape(
                  similarity_matrix
              )
          )
          return -1 * tf.ones(
              [similarity_matrix_shape[1]], dtype=tf.int32
          )
  
      def _match_when_rows_are_non_empty():
          """Performs matching when the rows of similarity matrix are non empty.
  
          Returns:
            matches:  int32 tensor indicating the row each column matches to.
          """
          # Matches for each column
          matches = tf.argmax(
              similarity_matrix, 0, output_type=tf.int32
          )
  
          # Deal with matched and unmatched threshold
          if self._matched_threshold is not None:
              # Get logical indices of ignored and unmatched columns as tf.int64
              matched_vals = tf.reduce_max(similarity_matrix, 0)
              below_unmatched_threshold = tf.greater(
                  self._unmatched_threshold, matched_vals
              )
              between_thresholds = tf.logical_and(
                  tf.greater_equal(
                      matched_vals, self._unmatched_threshold
                  ),
                  tf.greater(self._matched_threshold, matched_vals),
              )
  
              if self._negatives_lower_than_unmatched:
                  matches = self._set_values_using_indicator(
                      matches, below_unmatched_threshold, -1
                  )
                  matches = self._set_values_using_indicator(
                      matches, between_thresholds, -2
                  )
              else:
                  matches = self._set_values_using_indicator(
                      matches, below_unmatched_threshold, -2
                  )
                  matches = self._set_values_using_indicator(
                      matches, between_thresholds, -1
                  )
  
          if self._force_match_for_each_row:
              similarity_matrix_shape = (
                  shape_utils.combined_static_and_dynamic_shape(
                      similarity_matrix
                  )
              )
              force_match_column_ids = tf.argmax(
                  similarity_matrix, 1, output_type=tf.int32
              )
              force_match_column_indicators = tf.one_hot(
                  force_match_column_ids,
                  depth=similarity_matrix_shape[1],
              )
              force_match_row_ids = tf.argmax(
                  force_match_column_indicators, 0, output_type=tf.int32
              )
              force_match_column_mask = tf.cast(
                  tf.reduce_max(force_match_column_indicators, 0),
                  tf.bool,
              )
              final_matches = tf.where(
                  force_match_column_mask, force_match_row_ids, matches
              )
              return final_matches
          else:
              return matches
  
      if similarity_matrix.shape.is_fully_defined():
          if similarity_matrix.shape[0] == 0:
              return _match_when_rows_are_empty()
          else:
              return _match_when_rows_are_non_empty()
      else:
          return tf.cond(
              tf.greater(tf.shape(similarity_matrix)[0], 0),
              _match_when_rows_are_non_empty,
              _match_when_rows_are_empty,
          )
  
imports: import tensorflow.compat.v1
  from .None import matcher
  from .None import shape_utils
label_desc: Use image node_id 2 for calling the ArgMaxMatcher obj's underlying member method code with example usage: obj._match(similarity_matrix) and returns: unknown, tf, final_matches, matches, _match_when_rows_are_empty, _match_when_rows_are_non_empty