code: def _dedup_scopes(scopes):
      """Deduplicated scopes."""
      paths = []
      # must preseve insertion order for duplication to work correctly
      minimal_set = collections.OrderedDict((s, ()) for s in scopes)
      for leaf in scopes:
          scope = leaf.parent
          max_parent = leaf
          max_parent_path = ()
          path = [leaf.name]
          while scope is not None:
              if scope in minimal_set:
                  max_parent = scope
                  max_parent_path = tuple(reversed(path))
              path.append(scope.name)
              scope = scope.parent
          if max_parent is not leaf and leaf in minimal_set:
              del minimal_set[leaf]
          paths.append((max_parent, max_parent_path))
      return tuple(minimal_set), tuple(paths)
  
imports: import collections
  import dataclasses
  import functools
  from typing import Any, Callable, Dict, Generic, Iterable, List, Mapping, Optional, Sequence, Tuple, TypeVar, Union
  import warnings
  from flax import traceback_util
  import jax
  from jax import random
  from .None import axes_scan, meta
  from .frozen_dict import freeze, unfreeze
  from .scope import CollectionFilter, DenyList, Filter, PRNGSequenceFilter, Scope, group_collections, in_filter, intersect_filters, is_filter_empty, subtract_filters, union_filters
label_desc: Use image node_id 2 for calling a global function with example usage: _dedup_scopes(scopes) and returns: tuple,  tuple