code: def random_lil(shape, dtype, nnz):
      sp = pytest.importorskip("scipy")
      rval = sp.sparse.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.default_rng().integers(1, huge + 1, size=2)
              % shape
          )
          value = np.random.random()
          # if dtype *int*, value will always be zeros!
          if dtype in 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: import numpy
  import pytest
  import pytensor
  import pytensor.typed_list
  from pytensor import sparse
  from pytensor.tensor.type import TensorType, integer_dtypes, matrix, scalar, tensor3, vector
  from pytensor.tensor.type_other import SliceType
  from pytensor.tensor.variable import TensorVariable
  from pytensor.typed_list.basic import Append, Count, Extend, GetItem, Index, Insert, Length, Remove, Reverse, make_list
  from pytensor.typed_list.type import TypedListType
label_desc: Use image node_id 2 for calling a global function with example usage: random_lil(shape, dtype, nnz) and returns: rval