code: def to_prng_sequence(rng, err_msg) -> Optional[hk.PRNGSequence]:
      if rng is not None:
          try:
              rng = hk.PRNGSequence(rng)
          except Exception as e:
              raise ValueError(
                  f"{err_msg}. The object was of type {type(rng)}: {rng}"
              ) from e
      return rng
  
imports: from collections.abc import Mapping
  import inspect
  from typing import Any, Callable, NamedTuple, Optional, TypeVar, Union
  from haiku._src import analytics
  from haiku._src import base
  from haiku._src import data_structures
  from haiku._src import typing
  import jax
label_desc: Use image node_id 4 for calling a global function with example usage: to_prng_sequence(rng, err_msg) and returns: rng