code: def test_repr_niimgs():
      # Tests with file path
      assert _utils._repr_niimgs("test") == "test"
      assert _utils._repr_niimgs("test", shorten=False) == "test"
  
      # Shortening long names by default
      long_name = "this-is-a-very-long-name-for-a-nifti-file.nii"
      short_name = "this-is-a-very-lon..."
      assert _utils._repr_niimgs(long_name) == short_name
      # Explicit shortening of long names
      assert _utils._repr_niimgs(long_name, shorten=True) == short_name
  
      # Lists of long names up to length 3
      list_of_size_3 = [
          "this-is-a-very-long-name-for-a-nifti-file.nii",
          "this-is-another-very-long-name-for-a-nifti-file.nii",
          "this-is-again-another-very-long-name-for-a-nifti-file.nii",
      ]
      # Explicit shortening, all 3 names are displayed, but shortened
      shortened_rep_list_of_size_3 = (
          "[this-is-a-very-lon...,"
          " this-is-another-ve...,"
          " this-is-again-anot...]"
      )
  
      assert (
          _utils._repr_niimgs(list_of_size_3, shorten=True)
          == shortened_rep_list_of_size_3
      )
  
      # Lists longer than 3
      # Small names - Explicit shortening
      long_list_small_names = [
          "test",
          "retest",
          "reretest",
          "rereretest",
      ]
      shortened_rep_long_list_small_names = (
          "[test,\n         ...\n rereretest]"
      )
  
      assert (
          _utils._repr_niimgs(long_list_small_names, shorten=True)
          == shortened_rep_long_list_small_names
      )
  
      # Long names - Explicit shortening
      list_of_size_4 = list_of_size_3 + [
          "this-is-again-another-super-very-long-name-for-a-nifti-file.nii"
      ]
      shortened_rep_long_list_long_names = "[this-is-a-very-lon...,\n         ...\n this-is-again-anot...]"
  
      assert (
          _utils._repr_niimgs(list_of_size_4, shorten=True)
          == shortened_rep_long_list_long_names
      )
  
imports: import os
  import re
  import tempfile
  from pathlib import Path
  import nibabel
  import numpy
  import pytest
  from nibabel import Nifti1Image
  from numpy.testing import assert_array_equal
  import nilearn
  from nilearn import _utils
  from nilearn._utils import niimg_conversions, testing
  from nilearn._utils.exceptions import DimensionError
  from nilearn._utils.niimg_conversions import iter_check_niimg
  from nilearn._utils.testing import assert_memory_less_than, with_memory_profiler
  from nilearn.image import get_data
label_desc: Use image node_id 15 for calling a global function with example usage: test_repr_niimgs() without return types