class_docstr: Layer that computes a matching matrix between samples in two tensors.
  
  :param normalize: Whether to L2-normalize samples along the
      dot product axis before taking the dot product.
      If set to True, then the output of the dot product
      is the cosine proximity between the two samples.
  :param matching_type: the similarity function for matching
  :param kwargs: Standard layer keyword arguments.
  
  Examples:
      >>> import matchzoo as mz
      >>> layer = mz.layers.MatchingLayer(matching_type='dot',
      ...                                 normalize=True)
      >>> num_batch, left_len, right_len, num_dim = 5, 3, 2, 10
      >>> layer.build([[num_batch, left_len, num_dim],
      ...              [num_batch, right_len, num_dim]])
class_docstr_tok: ["Layer","that","computes","a","matching","matrix","between","samples","in","two","tensors",".",":","param","normalize",":","Whether","to","L2-normalize","samples","along","the","dot","product","axis","before","taking","the","dot","product",".","If","set","to","True",",","then","the","output","of","the","dot","product","is","the","cosine","proximity","between","the","two","samples",".",":","param","matching_type",":","the","similarity","function","for","matching",":","param","kwargs",":","Standard","layer","keyword","arguments",".","Examples",":",">",">",">","import","matchzoo","as","mz",">",">",">","layer","=","mz.layers.MatchingLayer","(","matching_type='dot","'",",","...","normalize=True",")",">",">",">","num_batch",",","left_len",",","right_len",",","num_dim","=","5",",","3",",","2",",","10",">",">",">","layer.build","(","[","[","num_batch",",","left_len",",","num_dim","]",",","...","[","num_batch",",","right_len",",","num_dim","]","]",")"]
docstr: The computation logic of MatchingLayer.
  
  :param inputs: two input tensors.
docstr_tok: ["The","computation","logic","of","MatchingLayer",".",":","param","inputs",":","two","input","tensors","."]
code: def call(self, inputs: list, **kwargs) -> typing.Any:
      """
      The computation logic of MatchingLayer.
  
      :param inputs: two input tensors.
      """
      x1 = inputs[0]
      x2 = inputs[1]
      if self._matching_type == "dot":
          if self._normalize:
              x1 = tf.math.l2_normalize(x1, axis=2)
              x2 = tf.math.l2_normalize(x2, axis=2)
          return tf.expand_dims(tf.einsum("abd,acd->abc", x1, x2), 3)
      else:
          if self._matching_type == "mul":
  
              def func(x, y):
                  return x * y
  
          elif self._matching_type == "plus":
  
              def func(x, y):
                  return x + y
  
          elif self._matching_type == "minus":
  
              def func(x, y):
                  return x - y
  
          elif self._matching_type == "concat":
  
              def func(x, y):
                  return tf.concat([x, y], axis=3)
  
          else:
              raise ValueError(
                  f"Invalid matching type."
                  f"{self._matching_type} received."
                  f"Mut be in `dot`, `mul`, `plus`, "
                  f"`minus` and `concat`."
              )
          x1_exp = tf.stack([x1] * self._shape2[1], 2)
          x2_exp = tf.stack([x2] * self._shape1[1], 1)
          return func(x1_exp, x2_exp)
  
file_path: MatchZoo/matchzoo/layers/matching_layer.py
imports: import typing
  import tensorflow
  from keras.engine import Layer
label_desc: Use image node_id 4 for calling the MatchingLayer obj's underlying member method code with example usage: obj.call(inputs) and returns: tf, func, unknown, unknown, unknown, tf