code: def ftheta(U, H1, permutohedrals, mu, kernel_weights, norms, name):
      """
      A mean-field update
  
      :param U: the unary potentials (before softmax)
      :param H1: the previous mean-field approximation to be updated
      :param permutohedrals: fixed position vectors for fast filtering
      :param mu: compatibility function
      :param kernel_weights: weights bilateral/spatial kernels
      :param norms: precomputed normalisation factor
      :param name: layer name
      :return: updated mean-field distribution
      """
      unary_shape = U.shape.as_list()
      n_ch = unary_shape[-1]
      H1 = tf.nn.softmax(H1)
      Q1 = 0
      for idx, permutohedral in enumerate(permutohedrals):
          # Message Passing
          Q = _permutohedral_gen(
              permutohedral, H1 * norms[idx], name + str(idx)
          )
          Q.set_shape(unary_shape)
          # Weighting Filtered Outputs
          Q1 += Q * kernel_weights[idx] * norms[idx]
  
      # Compatibility Transform, Adding Unary Potentials
      # output logits, not the softmax
      Q1 = tf.reshape(
          tf.matmul(tf.reshape(Q1, [-1, n_ch]), mu), unary_shape
      )
      return U - Q1
  
file_path: NiftyNet/niftynet/layer/crf.py
imports: from __future__ import absolute_import, print_function
  import numpy
  import tensorflow
  from niftynet.layer.base_layer import TrainableLayer
  from niftynet.layer.layer_util import infer_spatial_rank, expand_spatial_params
label_desc: Use image node_id 1 for calling a global function with example usage: ftheta(U, H1, permutohedrals, mu, kernel_weights, norms, name) and returns: unknown