code: def test_composition():
      t1 = Transform("in", "mid", mapping=id)
      t2 = Transform("mid", "out", mapping=mapping)
      pytest.raises(CompositionError, t1.composed_with, t1)
  
      # Check forward composition (transforms have forward mappings)
      t12 = t1.composed_with(t2)
      x, y, z = np.random.random((3, 10))
      np.testing.assert_equal(mapping(x, y, z), t12.mapping(x, y, z))
  
      # Check backward composition (transforms have reverse mappings)
      t21 = t2.get_inverse().composed_with(t1.get_inverse())
      x, y, z = np.random.random((3, 10))
      np.testing.assert_equal(
          mapping(x, y, z), t21.inverse_mapping(x, y, z)
      )
  
      # Check that you cannot compose transforms that do not have chainable
      # mappings
      pytest.raises(
          CompositionError, t1.composed_with, t1.get_inverse()
      )
  
file_path: nipy/nipy/labs/datasets/transforms/tests/test_transform.py
imports: import copy
  import numpy
  import pytest
  from ..transform import CompositionError, Transform
label_desc: Use image node_id 3 for calling a global function with example usage: test_composition() without return types