code: def test_a2f_nan2zero():
      ndt = np.dtype(np.float64)
      str_io = BytesIO()
      # nans set to 0 for integer output case, not float
      arr = np.array([[np.nan, 0], [0, np.nan]])
      data_back = write_return(
          arr, str_io, ndt
      )  # float, thus no effect
      assert_array_equal(data_back, arr)
      # True is the default, but just to show it's possible
      data_back = write_return(arr, str_io, ndt, nan2zero=True)
      assert_array_equal(data_back, arr)
      with np.errstate(invalid="ignore"):
          data_back = write_return(arr, str_io, np.int64, nan2zero=True)
      assert_array_equal(data_back, [[0, 0], [0, 0]])
      # otherwise things get a bit weird; tidied here
      # How weird?  Look at arr.astype(np.int64)
      with np.errstate(invalid="ignore"):
          data_back = write_return(
              arr, str_io, np.int64, nan2zero=False
          )
          assert_array_equal(data_back, arr.astype(np.int64))
  
imports: import bz2
  import functools
  import gzip
  import itertools
  import os
  import tempfile
  import threading
  import time
  import warnings
  from io import BytesIO
  from os.path import exists
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from packaging.version import Version
  from nibabel.testing import assert_allclose_safely, assert_dt_equal, error_warnings, suppress_warnings
  from ..casting import OK_FLOATS, floor_log2, sctypes, shared_range, type_info
  from ..openers import BZ2File, ImageOpener, Opener
  from ..optpkg import optional_package
  from ..tmpdirs import InTemporaryDirectory
  from ..volumeutils import _dt_min_max, _ftype4scaled_finite, _is_compressed_fobj, _write_data, apply_read_scaling, array_from_file, array_to_file, best_write_scale_ftype, better_float_of, fname_ext_ul_case, int_scinter_ftype, make_dt_codes, native_code, rec2dict, seek_tell, shape_zoom_affine, working_type, write_zeros
label_desc: Use image node_id 13 for calling a global function with example usage: test_a2f_nan2zero() without return types