code: def test_dist_to_corner(rng):
      affine = np.eye(4)
      # Calculate the distance with the pythagorean theorem:
      pythagoras = np.sqrt(np.sum((np.diag(affine)[:-1] / 2) ** 2))
      # Compare to calculation with this function:
      assert_array_almost_equal(dist_to_corner(affine), pythagoras)
      # Apply a rotation to the matrix, just to demonstrate the calculation is
      # robust to that:
      R = _rotation_from_angles(rng.random(3) * np.pi)
      new_aff = np.vstack([np.dot(R, affine[:3, :]), [0, 0, 0, 1]])
      assert_array_almost_equal(dist_to_corner(new_aff), pythagoras)
  
imports: import numpy
  import random
  from dipy.core.geometry import sphere2cart, cart2sphere, nearest_pos_semi_def, sphere_distance, cart_distance, vector_cosine, lambert_equal_area_projection_polar, circumradius, vec2vec_rotmat, vector_norm, compose_transformations, compose_matrix, decompose_matrix, perpendicular_directions, dist_to_corner, is_hemispherical
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_equal, assert_raises, assert_almost_equal
  from dipy.testing.spherepoints import sphere_points
  from dipy.testing.decorators import set_random_number_generator
  from dipy.core.sphere_stats import random_uniform_on_sphere
  from itertools import permutations
label_desc: Use image node_id 16 for calling a global function with example usage: test_dist_to_corner(rng) without return types