code: def random_lil(shape, dtype, nnz):
      rval = sp.lil_matrix(shape, dtype=dtype)
      huge = 2**30
      for k in range(nnz):
          # set non-zeros in random locations (row x, col y)
          idx = np.random.randint(1, huge + 1, size=2) % shape
          value = np.random.rand()
          # if dtype *int*, value will always be zeros!
          if dtype in theano.tensor.integer_dtypes:
              value = int(value * 100)
          # The call to tuple is needed as scipy 0.13.1 do not support
          # ndarray with length 2 as idx tuple.
          rval.__setitem__(tuple(idx), value)
      return rval
  
imports: from __future__ import absolute_import, print_function, division
  import unittest
  from nose.plugins.skip import SkipTest
  import numpy
  import theano
  import theano.typed_list
  from theano import tensor
  from theano.tensor.type_other import SliceType
  from theano.typed_list.type import TypedListType
  from theano.typed_list.basic import GetItem, Insert, Append, Extend, Remove, Reverse, Index, Count, Length, make_list
  from theano import sparse
  from theano.tests import unittest_tools
label_desc: Use image node_id 2 for calling a global function with example usage: random_lil(shape, dtype, nnz) and returns: rval