code: def _dm_row_density(M):
      """Density measure for sparse matrices.
  
      Defines the "density", ``d`` as the average number of non-zero entries per
      row except ignoring rows that are fully zero. RREF can ignore fully zero
      rows so they are excluded. By definition ``d >= 1`` except that we define
      ``d = 0`` for the zero matrix.
  
      Returns ``(density, nrows_nz, ncols)`` where ``nrows_nz`` counts the number
      of nonzero rows and ``ncols`` is the number of columns.
      """
      # Uses the SDM dict-of-dicts representation.
      ncols = M.shape[1]
      rows_nz = M.rep.to_sdm().values()
      if not rows_nz:
          return 0, 0, ncols
      else:
          nrows_nz = len(rows_nz)
          density = sum(map(len, rows_nz)) / nrows_nz
          return density, nrows_nz, ncols
  
file_path: sympy/sympy/polys/matrices/rref.py
imports: from sympy.polys.domains import ZZ
  from sympy.polys.matrices.sdm import SDM, sdm_irref, sdm_rref_den
  from sympy.polys.matrices.ddm import DDM
  from sympy.polys.matrices.dense import ddm_irref, ddm_irref_den
label_desc: Use image node_id 13 for calling a global function with example usage: _dm_row_density(M) and returns: int,  int,  ncols, density,  nrows_nz,  ncols