code: def intra_community_edges(G, partition):
      """Returns the number of intra-community edges for a partition of `G`.
  
      Parameters
      ----------
      G : NetworkX graph.
  
      partition : iterable of sets of nodes
          This must be a partition of the nodes of `G`.
  
      The "intra-community edges" are those edges joining a pair of nodes
      in the same block of the partition.
  
      """
      return sum(G.subgraph(block).size() for block in partition)
  
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 2 for calling a global function with example usage: intra_community_edges(G, partition) and returns: sum