code: def test_from_image():
      # from_image classmethod copies
      arr = np.arange(24).reshape((2, 3, 4))
      coordmap = AffineTransform.from_params("xyz", "ijk", np.eye(4))
      img = Image(arr, coordmap, metadata={"field": "value"})
      img2 = Image.from_image(img)
      assert_array_equal(img.get_fdata(), img2.get_fdata())
      assert img.coordmap == img2.coordmap
      assert img.metadata == img2.metadata
      assert not img.metadata is img2.metadata
      # optional inputs - data
      arr2 = arr + 10
      new = Image.from_image(img, arr2)
      assert_array_almost_equal(arr2, new.get_fdata())
      assert new.coordmap == coordmap
      new = Image.from_image(img, data=arr2)
      assert_array_almost_equal(arr2, new.get_fdata())
      assert new.coordmap == coordmap
      # optional inputs - coordmap
      coordmap2 = AffineTransform.from_params("pqr", "ijk", np.eye(4))
      new = Image.from_image(img, arr2, coordmap2)
      assert_array_almost_equal(arr2, new.get_fdata())
      assert new.coordmap == coordmap2
      new = Image.from_image(img, coordmap=coordmap2)
      assert_array_almost_equal(arr, new.get_fdata())
      assert new.coordmap == coordmap2
      # Optional inputs - metadata
      assert new.metadata == img.metadata
      another_meta = {"interesting": "information"}
      new = Image.from_image(img, arr2, coordmap2, another_meta)
      assert_array_almost_equal(arr2, new.get_fdata())
      assert another_meta == new.metadata
  
imports: import warnings
  from itertools import chain
  import nibabel
  import numpy
  import pytest
  from numpy.testing import assert_almost_equal, assert_array_almost_equal, assert_array_equal
  from ...api import data_generator, parcels, write_data
  from ...reference.coordinate_map import AffineTransform, AxisError
  from ...reference.coordinate_system import CoordinateSystem
  from ..None import image
  from ..image import Image, is_image, iter_axis, rollimg
label_desc: Use image node_id 17 for calling a global function with example usage: test_from_image() without return types