code: def test_downsample_non_native_endian_data(
      shape, affine_eye, endian_type, copy_data, rng
  ):
      """Test resampling with a 1/2 down-sampling affine with non native endians.
  
      Test to check that if giving non native endian data as input should
      work as normal and expected to return the same output as above tests.
  
      Big endian data ">f8"
      Little endian data "<f8"
      """
      data = rng.random(shape)
  
      rot_img = resample_img(
          Nifti1Image(data, affine_eye),
          target_affine=2 * affine_eye,
          interpolation="nearest",
      )
  
      downsampled = data[::2, ::2, ::2, ...]
      x, y, z = downsampled.shape[:3]
  
      assert_almost_equal(
          downsampled, get_data(rot_img)[:x, :y, :z, ...]
      )
  
      rot_img = resample_img(
          Nifti1Image(data.astype(endian_type), affine_eye),
          target_affine=2 * affine_eye,
          interpolation="nearest",
          copy=copy_data,
      )
  
      assert_almost_equal(
          downsampled, get_data(rot_img)[:x, :y, :z, ...]
      )
  
imports: import copy
  import math
  import os
  from pathlib import Path
  import numpy
  import pytest
  from nibabel import Nifti1Header, Nifti1Image
  from nibabel.freesurfer import MGHImage
  from numpy.testing import assert_allclose, assert_almost_equal, assert_array_almost_equal, assert_array_equal, assert_equal
  from nilearn import _utils
  from nilearn._utils import testing
  from nilearn.conftest import _affine_eye, _rng
  from nilearn.image import get_data
  from nilearn.image.image import _pad_array, crop_img
  from nilearn.image.resampling import BoundingBoxError, coord_transform, from_matrix_vector, get_bounds, reorder_img, resample_img, resample_to_img
label_desc: Use image node_id 7 for calling a global function with example usage: test_downsample_non_native_endian_data(shape, affine_eye, endian_type, copy_data, rng) without return types