code: def _from_haiku_params(params: hk.Params) -> FlaxCollection:
      """Converts Haiku parameters to a nested Flax collection."""
      collection = {}
      for mod_name, name, value in hkds.traverse(params):
          if mod_name == "~":
              collection[name] = value
          else:
              nested_collection = collection
              for part in mod_name.split("/"):
                  if part not in nested_collection:
                      nested_collection[part] = {}
                  nested_collection = nested_collection[part]
              nested_collection[name] = value
      return collection
  
file_path: dm-haiku/haiku/_src/flax/transform_flax.py
imports: from collections.abc import Mapping
  from typing import Any, Callable
  import flax.errors
  import flax.linen
  from haiku._src import base
  from haiku._src import filtering
  from haiku._src import lift
  from haiku._src import transform
  from haiku._src import typing
  from haiku._src.flax import utils
label_desc: Use image node_id 1 for calling a global function with example usage: _from_haiku_params(params) and returns: collection