code: def sparse_rand(shape, frac=0.05, round_up=False):
      # generate an input with sparse activation
      # in the input dimension for LSTM testing
      # frac is the fraction of the matrix elements
      # which will be nonzero. Set round_up to
      # True to get a binary matrix, i.e. elements
      # are either set to 0 or 1
      num_el = np.prod(shape)
      inds = nprnd.permutation(num_el)[0 : int(frac * num_el)]
  
      # draw frac*num_el random numbers
      vals = nprnd.random(inds.size)
  
      if round_up:
          vals = np.ceil(vals)
      out = np.zeros(shape)
      out.flat[inds] = vals
      return (out, inds)
  
file_path: neon/tests/utils.py
imports: from builtins import zip
  import numpy
  import numpy.random
  from neon import logger
  from neon.backends.backend import Tensor
label_desc: Use image node_id 1 for calling a global function with example usage: sparse_rand(shape, frac, round_up) and returns: out,  inds