code: def test_tracking_max_angle(rng):
      """This tests that the angle between streamline points is always smaller
      then the input `max_angle` parameter.
      """
  
      def get_min_cos_similarity(streamlines):
          min_cos_sim = 1
          for sl in streamlines:
              if len(sl) > 1:
                  v = sl[:-1] - sl[1:]  # vectors have norm of 1
                  for i in range(len(v) - 1):
                      cos_sim = np.dot(v[i], v[i + 1])
                      if cos_sim < min_cos_sim:
                          min_cos_sim = cos_sim
          return min_cos_sim
  
      for sphere in [
          get_sphere("repulsion100"),
          HemiSphere.from_sphere(get_sphere("repulsion100")),
      ]:
          shape_img = [5, 5, 5]
          shape_img.extend([sphere.vertices.shape[0]])
          mask = np.ones(shape_img[:3])
          affine = np.eye(4)
          random_pmf = rng.random(shape_img)
          seeds = seeds_from_mask(mask, affine, density=1)
          sc = ActStoppingCriterion.from_pve(
              mask, np.zeros(shape_img[:3]), np.zeros(shape_img[:3])
          )
          max_angle = 20
          step_size = 1
          dg = ProbabilisticDirectionGetter.from_pmf(
              random_pmf, max_angle, sphere, pmf_threshold=0.1
          )
          # local tracking
          streamlines = Streamlines(
              LocalTracking(dg, sc, seeds, affine, step_size)
          )
          min_cos_sim = get_min_cos_similarity(streamlines)
          npt.assert_(np.arccos(min_cos_sim) <= np.deg2rad(max_angle))
  
          # PFT tracking
          streamlines = Streamlines(
              ParticleFilteringTracking(dg, sc, seeds, affine, 1.0)
          )
          min_cos_sim = get_min_cos_similarity(streamlines)
          npt.assert_(np.arccos(min_cos_sim) <= np.deg2rad(max_angle))
  
imports: from logging import warn
  import warnings
  import nibabel
  import numpy
  import numpy.testing
  from dipy.core.gradients import gradient_table
  from dipy.core.sphere import HemiSphere, unit_octahedron
  from dipy.data import get_fnames, get_sphere
  from dipy.direction import BootDirectionGetter, ClosestPeakDirectionGetter, DeterministicMaximumDirectionGetter, PeaksAndMetrics, ProbabilisticDirectionGetter, PTTDirectionGetter
  from dipy.reconst.csdeconv import ConstrainedSphericalDeconvModel
  from dipy.reconst.shm import descoteaux07_legacy_msg
  from dipy.tracking.local_tracking import LocalTracking, ParticleFilteringTracking
  from dipy.tracking.streamline import Streamlines
  from dipy.tracking.stopping_criterion import ActStoppingCriterion, BinaryStoppingCriterion, ThresholdStoppingCriterion, StreamlineStatus
  from dipy.tracking.utils import random_seeds_from_mask, seeds_from_mask
  from dipy.sims.voxel import single_tensor, multi_tensor
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 4 for calling a global function with example usage: test_tracking_max_angle(rng) and returns: min_cos_sim