code: def _compose_cmaps(*cmaps):
      """Compute the composition of a sequence of cmaps"""
  
      def _compose2(cmap1, cmap2):
          forward = lambda input: cmap1.function(cmap2.function(input))
          cmap1i = cmap1.inverse()
          cmap2i = cmap2.inverse()
          if cmap1i is not None and cmap2i is not None:
              backward = lambda output: cmap2i.function(
                  cmap1i.function(output)
              )
          else:
              backward = None
          return forward, backward
  
      # the identity coordmap
      cur = CoordinateMap(
          cmaps[-1].function_domain,
          cmaps[-1].function_domain,
          lambda x: x,
          lambda x: x,
      )
      for cmap in cmaps[::-1]:
          if cmap.function_domain == cur.function_range:
              forward, backward = _compose2(cmap, cur)
              cur = CoordinateMap(
                  cur.function_domain,
                  cmap.function_range,
                  forward,
                  inverse_function=backward,
              )
          else:
              raise ValueError(
                  "domain and range coordinates do not match: "
                  f"domain={cmap.function_domain.dtype}, range={cur.function_range.dtype}"
              )
  
      return cur
  
imports: import warnings
  import numpy
  import numpy.linalg
  from nibabel import io_orientation
  from nibabel.affines import from_matvec, to_matvec
  from .coordinate_system import CoordinateSystem, is_coordsys, safe_dtype
  from .coordinate_system import product
label_desc: Use image node_id 12 for calling a global function with example usage: _compose_cmaps() and returns: cur, forward,  backward