code: def number_attracting_components(G):
      """Returns the number of attracting components in `G`.
  
      Parameters
      ----------
      G : DiGraph, MultiDiGraph
          The graph to be analyzed.
  
      Returns
      -------
      n : int
          The number of attracting components in G.
  
      Raises
      ------
      NetworkXNotImplemented
          If the input graph is undirected.
  
      See Also
      --------
      attracting_components
      is_attracting_component
  
      """
      return sum(1 for ac in attracting_components(G))
  
imports: import networkx
  from networkx.utils.decorators import not_implemented_for
label_desc: Use image node_id 2 for calling a global function with example usage: number_attracting_components(G) and returns: sum