code: def assert_dig_allclose(info_py, info_bin, limit=None):
      """Assert dig allclose."""
      from .._fiff.constants import FIFF
      from .._fiff.meas_info import Info
      from ..bem import fit_sphere_to_headshape
      from ..channels.montage import DigMontage
  
      # test dig positions
      dig_py, dig_bin = info_py, info_bin
      if isinstance(dig_py, Info):
          assert isinstance(dig_bin, Info)
          dig_py, dig_bin = dig_py["dig"], dig_bin["dig"]
      else:
          assert isinstance(dig_bin, DigMontage)
          assert isinstance(dig_py, DigMontage)
          dig_py, dig_bin = dig_py.dig, dig_bin.dig
          info_py = info_bin = None
      assert isinstance(dig_py, list)
      assert isinstance(dig_bin, list)
      dig_py = sorted(dig_py, key=_dig_sort_key)
      dig_bin = sorted(dig_bin, key=_dig_sort_key)
      assert len(dig_py) == len(dig_bin)
      for ii, (d_py, d_bin) in enumerate(
          zip(dig_py[:limit], dig_bin[:limit])
      ):
          for key in ("ident", "kind", "coord_frame"):
              assert d_py[key] == d_bin[key], key
          assert_allclose(
              d_py["r"],
              d_bin["r"],
              rtol=1e-5,
              atol=1e-5,
              err_msg="Failure on %s:\n%s\n%s"
              % (ii, d_py["r"], d_bin["r"]),
          )
      if (
          any(d["kind"] == FIFF.FIFFV_POINT_EXTRA for d in dig_py)
          and info_py is not None
      ):
          r_bin, o_head_bin, o_dev_bin = fit_sphere_to_headshape(
              info_bin, units="m", verbose="error"
          )
          r_py, o_head_py, o_dev_py = fit_sphere_to_headshape(
              info_py, units="m", verbose="error"
          )
          assert_allclose(r_py, r_bin, atol=1e-6)
          assert_allclose(o_dev_py, o_dev_bin, rtol=1e-5, atol=1e-6)
          assert_allclose(o_head_py, o_head_bin, rtol=1e-5, atol=1e-6)
  
imports: import inspect
  import os
  import sys
  import tempfile
  import traceback
  from functools import wraps
  from io import StringIO
  from shutil import rmtree
  from unittest import SkipTest
  import numpy
  from numpy.testing import assert_allclose, assert_array_equal
  from scipy import linalg
  from ._logging import ClosingStringIO, warn
  from .check import check_version
  from .misc import run_subprocess
  from .numerics import object_diff
label_desc: Use image node_id 20 for calling a global function with example usage: assert_dig_allclose(info_py, info_bin, limit) without return types