code: def rbf(X, X2=None, lengthscale=1.0, variance=1.0):
      """Radial basis function kernel, also known as the squared
      exponential or exponentiated quadratic. It is defined as
  
      $k(x, x') = \sigma^2 \exp\Big(
          -\\frac{1}{2} \sum_{d=1}^D \\frac{1}{\ell_d^2} (x_d - x'_d)^2 \Big)$
  
      for output variance $\sigma^2$ and lengthscale $\ell^2$.
  
      The kernel is evaluated over all pairs of rows, `k(X[i, ], X2[j, ])`.
      If `X2` is not specified, then it evaluates over all pairs
      of rows in `X`, `k(X[i, ], X[j, ])`. The output is a matrix
      where each entry (i, j) is the kernel over the ith and jth rows.
  
      Args:
        X: tf.Tensor.
          N x D matrix of N data points each with D features.
        X2: tf.Tensor.
          N x D matrix of N data points each with D features.
        lengthscale: tf.Tensor.
          Lengthscale parameter, a positive scalar or D-dimensional vector.
        variance: tf.Tensor.
          Output variance parameter, a positive scalar.
  
      #### Examples
  
      ```python
      X = tf.random_normal([100, 5])
      K = ed.rbf(X)
      assert K.shape == (100, 100)
      ```
      """
      lengthscale = tf.convert_to_tensor(lengthscale)
      variance = tf.convert_to_tensor(variance)
      dependencies = [
          tf.assert_positive(lengthscale),
          tf.assert_positive(variance),
      ]
      lengthscale = control_flow_ops.with_dependencies(
          dependencies, lengthscale
      )
      variance = control_flow_ops.with_dependencies(
          dependencies, variance
      )
  
      X = tf.convert_to_tensor(X)
      X = X / lengthscale
      Xs = tf.reduce_sum(tf.square(X), 1)
      if X2 is None:
          X2 = X
          X2s = Xs
      else:
          X2 = tf.convert_to_tensor(X2)
          X2 = X2 / lengthscale
          X2s = tf.reduce_sum(tf.square(X2), 1)
  
      square = (
          tf.reshape(Xs, [-1, 1])
          + tf.reshape(X2s, [1, -1])
          - 2 * tf.matmul(X, X2, transpose_b=True)
      )
      output = variance * tf.exp(-square / 2)
      return output
  
file_path: edward/edward/util/tensorflow.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
  from tensorflow.python.ops import control_flow_ops
label_desc: Use image node_id 2 for calling a global function with example usage: rbf(X, X2, lengthscale, variance) and returns: output