def inline_anonymous_sequentials(tree: Any) -> Any:
  """Inlines instances of `Sequential` (not subclasses) into parent groups."""
  return inline_groups(
      tree,
      parent_filter=is_sequential_or_named,
      child_filter=is_anonymous_sequential,
  )
Inlines instances of `Sequential` (not subclasses) into parent groups.
penzai/nn/grouping.py