class_docstr: MatchingHistogramUnit Class.
  
  :param bin_size: The number of bins of the matching histogram.
  :param embedding_matrix: The word embedding matrix applied to calculate
                           the matching histogram.
  :param normalize: Boolean, normalize the embedding or not.
  :param mode: The type of the historgram, it should be one of 'CH', 'NG',
               or 'LCH'.
  
  Examples:
      >>> embedding_matrix = np.array([[1.0, -1.0], [1.0, 2.0], [1.0, 3.0]])
      >>> text_left = [0, 1]
      >>> text_right = [1, 2]
      >>> histogram = MatchingHistogram(3, embedding_matrix, True, 'CH')
      >>> histogram.transform([text_left, text_right])
      [[3.0, 1.0, 1.0], [1.0, 2.0, 2.0]]
docstr: Transform the input text.
docstr_tok: ["Transform","the","input","text","."]
code: def transform(self, input_: list) -> list:
      """Transform the input text."""
      text_left, text_right = input_
      matching_hist = np.ones(
          (len(text_left), self._hist_bin_size), dtype=np.float32
      )
      embed_left = self._embedding_matrix[text_left]
      embed_right = self._embedding_matrix[text_right]
      matching_matrix = embed_left.dot(np.transpose(embed_right))
      for (i, j), value in np.ndenumerate(matching_matrix):
          bin_index = int(
              (value + 1.0) / 2.0 * (self._hist_bin_size - 1.0)
          )
          matching_hist[i][bin_index] += 1.0
      if self._mode == "NH":
          matching_sum = matching_hist.sum(axis=1)
          matching_hist = matching_hist / matching_sum[:, np.newaxis]
      elif self._mode == "LCH":
          matching_hist = np.log(matching_hist)
      return matching_hist.tolist()
  
imports: import numpy
  from .unit import Unit
label_desc: Use image node_id 3 for calling the MatchingHistogram obj's underlying member method code with example usage: obj.transform(input_) and returns: matching_hist