code: def bin_matrix(M, subsampling_factor=3):
      
  
      try:
          from scipy.sparse import issparse
          if issparse(M):
              return bin_sparse(M, subsampling_factor=subsampling_factor)
          else:
              raise ImportError
      except ImportError:
          return bin_dense(M, subsampling_factor=subsampling_factor)
docs: Bin either sparse or dense matrices.