class_docstr: Represents a morphism which is a composition of other morphisms.
  
  Explanation
  ===========
  
  Two composite morphisms are equal if the morphisms they were
  obtained from (components) are the same and were listed in the
  same order.
  
  The arguments to the constructor for this class should be listed
  in diagram order: to obtain the composition `g\circ f` from the
  instances of :class:`Morphism` ``g`` and ``f`` use
  ``CompositeMorphism(f, g)``.
  
  Examples
  ========
  
  >>> from sympy.categories import Object, NamedMorphism, CompositeMorphism
  >>> A = Object("A")
  >>> B = Object("B")
  >>> C = Object("C")
  >>> f = NamedMorphism(A, B, "f")
  >>> g = NamedMorphism(B, C, "g")
  >>> g * f
  CompositeMorphism((NamedMorphism(Object("A"), Object("B"), "f"),
  NamedMorphism(Object("B"), Object("C"), "g")))
  >>> CompositeMorphism(f, g) == g * f
  True
class_docstr_tok: ["Represents","a","morphism","which","is","a","composition","of","other","morphisms",".","Explanation","===========","Two","composite","morphisms","are","equal","if","the","morphisms","they","were","obtained","from","(","components",")","are","the","same","and","were","listed","in","the","same","order",".","The","arguments","to","the","constructor","for","this","class","should","be","listed","in","diagram","order",":","to","obtain","the","composition","`","g\\circ","f","`","from","the","instances","of",":","class",":","`","Morphism","`","``","g","``","and","``","f","``","use","``","CompositeMorphism","(","f",",","g",")","``",".","Examples","========",">",">",">","from","sympy.categories","import","Object",",","NamedMorphism",",","CompositeMorphism",">",">",">","A","=","Object","(","``","A","''",")",">",">",">","B","=","Object","(","``","B","''",")",">",">",">","C","=","Object","(","``","C","''",")",">",">",">","f","=","NamedMorphism","(","A",",","B",",","``","f","''",")",">",">",">","g","=","NamedMorphism","(","B",",","C",",","``","g","''",")",">",">",">","g","*","f","CompositeMorphism","(","(","NamedMorphism","(","Object","(","``","A","''",")",",","Object","(","``","B","''",")",",","``","f","''",")",",","NamedMorphism","(","Object","(","``","B","''",")",",","Object","(","``","C","''",")",",","``","g","''",")",")",")",">",">",">","CompositeMorphism","(","f",",","g",")","==","g","*","f","True"]
code: def __new__(cls, *components):
      if components and not isinstance(components[0], Morphism):
          # Maybe the user has explicitly supplied a list of
          # morphisms.
          return CompositeMorphism.__new__(cls, *components[0])
  
      normalised_components = Tuple()
  
      for current, following in zip(components, components[1:]):
          if not isinstance(current, Morphism) or not isinstance(
              following, Morphism
          ):
              raise TypeError("All components must be morphisms.")
  
          if current.codomain != following.domain:
              raise ValueError("Uncomposable morphisms.")
  
          normalised_components = CompositeMorphism._add_morphism(
              normalised_components, current
          )
  
      # We haven't added the last morphism to the list of normalised
      # components.  Add it now.
      normalised_components = CompositeMorphism._add_morphism(
          normalised_components, components[-1]
      )
  
      if not normalised_components:
          # If ``normalised_components`` is empty, only identities
          # were supplied.  Since they all were composable, they are
          # all the same identities.
          return components[0]
      elif len(normalised_components) == 1:
          # No sense to construct a whole CompositeMorphism.
          return normalised_components[0]
  
      return Basic.__new__(cls, normalised_components)
  
imports: from sympy.core import S, Basic, Dict, Symbol, Tuple, sympify
  from sympy.core.symbol import Str
  from sympy.sets import Set, FiniteSet, EmptySet
  from sympy.utilities.iterables import iterable
label_desc: Use image node_id 2 for calling the CompositeMorphism obj's underlying member method code with example usage: obj.__new__(cls) and returns: Basic, CompositeMorphism, components, normalised_components