code: def test_composition_and_decomposition():
      import numpy.array_api as np
  
      x = np.arange(2 * 3 * 5 * 7)
      x = np.reshape(x, (2, 3, 5, 7))
      comp = CompositionDecomposition(
          decomposed_shape=["a", "b", "c", "d"],
          composed_shape=[["a", "b"], ["c", "d"]],
      )
      assert comp.compose(x, known_axes_lengths={}).shape == (
          2 * 3,
          5 * 7,
      )
  
      y = CompositionDecomposition(
          decomposed_shape=["a", "b", "c", "d"],
          composed_shape=[["a", "b"], [], ["c", "d"]],
      ).compose(x, {})
      assert y.shape == (2 * 3, 1, 5 * 7)
      assert np.all(np.reshape(x, (-1,)) == np.reshape(y, (-1,)))
  
      comp = CompositionDecomposition(
          decomposed_shape=["a", "b", "e", "c", "d"],
          composed_shape=[["e", "c"], ["b"], ["a", "d"]],
      )
      x = np.arange(2 * 3 * 5 * 7 * 3)
      x = np.reshape(x, (2, 3, 5, 7, 3))
  
      axes = {}
      y = comp.compose(x, axes)
      x2 = comp.decompose(y, axes)
      assert np.all(x == x2)
  
file_path: einops/einops/experimental/indexing.py
imports: from typing import List, Union, TypeVar, Tuple
  from einops import EinopsError
label_desc: Use image node_id 3 for calling a global function with example usage: test_composition_and_decomposition() without return types