code: def count_nonzero_wrapper(X, optype):
      """Wrapper for handling sparse and dense versions of `tf.count_nonzero`.
  
      Parameters
      ----------
      X : tf.Tensor (N, K)
      optype : str, {'dense', 'sparse'}
  
      Returns
      -------
      tf.Tensor (1,K)
      """
      with tf.name_scope("count_nonzero_wrapper") as scope:
          if optype == "dense":
              return tf.count_nonzero(X, axis=0, keep_dims=True)
          elif optype == "sparse":
              indicator_X = tf.SparseTensor(
                  X.indices, tf.ones_like(X.values), X.dense_shape
              )
              return tf.sparse_reduce_sum(
                  indicator_X, axis=0, keep_dims=True
              )
          else:
              raise NameError(
                  "Unknown input type in count_nonzero_wrapper"
              )
  
file_path: tffm/tffm/utils.py
imports: import math
  import numpy
  import tensorflow
  import itertools
  from itertools import combinations_with_replacement, takewhile, count
  from collections import defaultdict
label_desc: Use image node_id 7 for calling a global function with example usage: count_nonzero_wrapper(X, optype) and returns: tf, tf