code: def test_lazy_tractogram_len(self):
      modules = [
          module_tractogram
      ]  # Modules for which to catch warnings.
      with clear_and_catch_warnings(record=True, modules=modules) as w:
          warnings.simplefilter("always")  # Always trigger warnings.
  
          # Calling `len` will create new generators each time.
          tractogram = LazyTractogram(DATA["streamlines_func"])
          assert tractogram._nb_streamlines is None
  
          # This should produce a warning message.
          assert len(tractogram) == len(DATA["streamlines"])
          assert tractogram._nb_streamlines == len(DATA["streamlines"])
          assert len(w) == 1
  
          tractogram = LazyTractogram(DATA["streamlines_func"])
  
          # New instances should still produce a warning message.
          assert len(tractogram) == len(DATA["streamlines"])
          assert len(w) == 2
          assert issubclass(w[-1].category, Warning) is True
  
          # Calling again 'len' again should *not* produce a warning.
          assert len(tractogram) == len(DATA["streamlines"])
          assert len(w) == 2
  
      with clear_and_catch_warnings(record=True, modules=modules) as w:
          # Once we iterated through the tractogram, we know the length.
  
          tractogram = LazyTractogram(DATA["streamlines_func"])
  
          assert tractogram._nb_streamlines is None
          [t for t in tractogram]  # Force iteration through tractogram.
          assert tractogram._nb_streamlines == len(DATA["streamlines"])
          # This should *not* produce a warning.
          assert len(tractogram) == len(DATA["streamlines"])
          assert len(w) == 0
  
imports: import copy
  import operator
  import sys
  import unittest
  import warnings
  from collections import defaultdict
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from ...testing import assert_arrays_equal, clear_and_catch_warnings
  from ..None import tractogram
  from ..tractogram import LazyDict, LazyTractogram, PerArrayDict, PerArraySequenceDict, Tractogram, TractogramItem, is_data_dict, is_lazy_dict
label_desc: Use image node_id 5 for calling the TestLazyTractogram obj's underlying member method code with example usage: obj.test_lazy_tractogram_len() without return types