code: def _require_partition(G, partition):
      """Decorator to check that a valid partition is input to a function
  
      Raises :exc:`networkx.NetworkXError` if the partition is not valid.
  
      This decorator should be used on functions whose first two arguments
      are a graph and a partition of the nodes of that graph (in that
      order)::
  
          >>> @require_partition
          ... def foo(G, partition):
          ...     print("partition is valid!")
          ...
          >>> G = nx.complete_graph(5)
          >>> partition = [{0, 1}, {2, 3}, {4}]
          >>> foo(G, partition)
          partition is valid!
          >>> partition = [{0}, {2, 3}, {4}]
          >>> foo(G, partition)
          Traceback (most recent call last):
            ...
          networkx.exception.NetworkXError: `partition` is not a valid partition of the nodes of G
          >>> partition = [{0, 1}, {1, 2, 3}, {4}]
          >>> foo(G, partition)
          Traceback (most recent call last):
            ...
          networkx.exception.NetworkXError: `partition` is not a valid partition of the nodes of G
  
      """
      if is_partition(G, partition):
          return G, partition
      raise nx.NetworkXError(
          "`partition` is not a valid partition of the nodes of G"
      )
  
file_path: networkx/networkx/algorithms/community/quality.py
imports: from itertools import combinations
  import networkx
  from networkx import NetworkXError
  from networkx.algorithms.community.community_utils import is_partition
  from networkx.utils.decorators import argmap
label_desc: Use image node_id 1 for calling a global function with example usage: _require_partition(G, partition) and returns: G,  partition