code: def scatter_mean(messages, indices, n_nodes):
      """
      Averages messages according to the segments defined by `indices`, with
      support for messages in single/disjoint mode (rank 2) and mixed mode (rank 3).
      The output has the same rank as the input, with the "nodes" dimension
      changed to `n_nodes`.
  
      For single/disjoint mode, messages are expected to have shape
      `[n_messages, n_features]` and the output will have shape
      `[n_nodes, n_features]`.
  
      For mixed mode, messages are expected to have shape
      `[batch, n_messages, n_features]` and the output will have shape
      `[batch, n_nodes, n_features]`.
  
      Indices are always expected to be a 1D tensor of integers < `n_nodes`, with
      shape '[n_messages]'.
      For any missing index (i.e., any integer `0 <= i < n_nodes` that does not
      appear in `indices`) the corresponding output will be all zeros.
      If a given index `i` is negative, it is ignored in the aggregation.
  
      :param messages: a 2D or 3D Tensor.
      :param indices: A 1D Tensor with indices into the "nodes" dimension of the
      messages.
      :param n_nodes: dimension of the output along the "nodes" dimension.
      :return: a Tensor with the same rank as `messages`.
      """
      return tf.math.unsorted_segment_mean(messages, indices, n_nodes)
  
file_path: spektral/spektral/layers/ops/scatter.py
imports: import tensorflow
label_desc: Use image node_id 3 for calling a global function with example usage: scatter_mean(messages, indices, n_nodes) and returns: tf