code: def _is_data_per_point_valid(streamlines, data):
      """Verify that the number of item in data is X and that each of these
          items has Y_i items.
  
          X being the number of streamlines
          Y_i being the number of points on streamlines #i
  
      Parameters
      ----------
      streamlines : list or ArraySequence
          Streamlines of the tractogram
      data : dict
          Contains the organized point's metadata (hopefully)
      Returns
      -------
      output : bool
          Does all the streamlines and metadata attribute match
      """
      if not isinstance(data, (dict, PerArraySequenceDict)):
          logger.error("data_per_point MUST be a dictionary.")
          return False
      elif data == {}:
          return True
  
      total_point = 0
      total_streamline = 0
      for i in streamlines:
          total_streamline += 1
          total_point += len(i)
  
      for key in data.keys():
          total_point_entries = 0
          if not len(data[key]) == total_streamline:
              logger.error(
                  "Missing entry for streamlines points data, "
                  "inconsistent number of streamlines."
              )
              return False
  
          for values in data[key]:
              total_point_entries += len(values)
  
          if total_point_entries != total_point:
              logger.error(
                  "Missing entry for streamlines points data, "
                  "inconsistent number of points per streamlines."
              )
              return False
  
      return True
  
imports: from bisect import bisect
  from collections import OrderedDict
  from copy import deepcopy
  import enum
  from itertools import product
  import logging
  from nibabel.affines import apply_affine
  from nibabel.streamlines.tractogram import Tractogram, PerArraySequenceDict, PerArrayDict
  import numpy
  from dipy.io.dpy import Streamlines
  from dipy.io.utils import get_reference_info, is_reference_info_valid, is_header_compatible
label_desc: Use image node_id 2 for calling a global function with example usage: _is_data_per_point_valid(streamlines, data) and returns: True, False, True, False, False