code: def difference_matrix(
      X: tf.Tensor, X2: Optional[tf.Tensor]
  ) -> tf.Tensor:
      """
      Returns (X - X2ᵀ)
      """
      if X2 is None:
          X2 = X
          diff = X[..., :, tf.newaxis, :] - X2[..., tf.newaxis, :, :]
          return diff
      Xshape = tf.shape(X)
      X2shape = tf.shape(X2)
      X = tf.reshape(X, (-1, Xshape[-1]))
      X2 = tf.reshape(X2, (-1, X2shape[-1]))
      diff = X[:, tf.newaxis, :] - X2[tf.newaxis, :, :]
      diff = tf.reshape(
          diff, tf.concat((Xshape[:-1], X2shape[:-1], [Xshape[-1]]), 0)
      )
      return diff
  
file_path: GPflow/gpflow/utilities/ops.py
imports: import copy
  from typing import Any, Callable, List, Optional
  import tensorflow
  import tensorflow_probability
  from check_shapes import check_shapes
label_desc: Use image node_id 5 for calling a global function with example usage: difference_matrix(X, X2) and returns: diff, diff