code: def test_memory_usage():
      # Valid measures (larger objects)
      for mem in (500, 200):
          assert_memory_less_than(
              mem, 0.1, create_object, mem * 1024**2
          )
  
      # Ensure an exception is raised with too small objects as
      # memory_profiler can return non trustable memory measure in this case.
      with pytest.raises(
          ValueError,
          match="Memory profiler measured an untrustable memory",
      ):
          assert_memory_less_than(
              50, 0.1, create_object, 25 * 1024**2
          )
  
      # Ensure ValueError is raised if memory used is above expected memory
      # limit.
      with pytest.raises(
          ValueError, match="Memory consumption measured"
      ):
          assert_memory_less_than(
              100, 0.1, create_object, 200 * 1024**2
          )
  
file_path: nilearn/nilearn/_utils/tests/test_testing.py
imports: import warnings
  import nibabel
  import numpy
  import pytest
  from nilearn._utils.testing import assert_memory_less_than, check_deprecation, with_memory_profiler, write_imgs_to_path
label_desc: Use image node_id 2 for calling a global function with example usage: test_memory_usage() without return types