code: def _assert_same(array_impl_type):
      def _assert_same_impl(path, new, old):
          typenew = type(new)
          typeold = type(old)
          if typeold is jax.ShapeDtypeStruct:
              typeold = array_impl_type
          if typenew is not typeold:
              raise RuntimeError(
                  f"Deserialised leaf at path '{jtu.keystr(path)}' has changed type from "
                  f"{type(old)} in `like` to {type(new)} on disk."
              )
          if isinstance(new, (np.ndarray, jax.Array)):
              if new.shape != old.shape:
                  raise RuntimeError(
                      f"Deserialised leaf at path {path} has changed shape from "
                      f"{old.shape} in `like` to {new.shape} on disk."
                  )
              if new.dtype != old.dtype:
                  raise RuntimeError(
                      f"Deserialised leaf at path {path} has changed dtype from "
                      f"{old.dtype} in `like` to {new.dtype} on disk."
                  )
  
      return _assert_same_impl
  
imports: import functools
  import pathlib
  from collections.abc import Callable
  from contextlib import contextmanager
  from typing import Any, BinaryIO, Optional, Union
  import jax
  import jax.numpy
  import jax.tree_util
  import numpy
  from jaxtyping import PyTree
  from ._filters import is_array_like
label_desc: Use image node_id 6 for calling a global function with example usage: _assert_same(array_impl_type) and returns: _assert_same_impl