code: def segment_mean(
      data: jnp.ndarray,
      segment_ids: jnp.ndarray,
      num_segments: Optional[int] = None,
      indices_are_sorted: bool = False,
      unique_indices: bool = False,
  ):
      """Returns mean for each segment.
  
      Args:
        data: the values which are averaged segment-wise.
        segment_ids: indices for the segments.
        num_segments: total number of segments.
        indices_are_sorted: whether ``segment_ids`` is known to be sorted.
        unique_indices: whether ``segment_ids`` is known to be free of duplicates.
      """
      nominator = segment_sum(
          data,
          segment_ids,
          num_segments,
          indices_are_sorted=indices_are_sorted,
          unique_indices=unique_indices,
      )
      denominator = segment_sum(
          jnp.ones_like(data),
          segment_ids,
          num_segments,
          indices_are_sorted=indices_are_sorted,
          unique_indices=unique_indices,
      )
      return nominator / jnp.maximum(
          denominator, jnp.ones(shape=[], dtype=denominator.dtype)
      )
  
imports: import functools
  from typing import Any, Callable, Generator, Iterable, Iterator, List, Mapping, Optional, Sequence, Union
  import jax
  from jax import lax
  import jax.numpy
  import jax.tree_util
  from jraph._src import graph
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: segment_mean(data, segment_ids, num_segments, indices_are_sorted, unique_indices) and returns: unknown