code: def gen_data():
      # generate the dataset
      train_set = (
          np.asarray(np.random.rand(10000, 784), dtype="float32"),
          np.asarray(np.random.rand(10000) * 10, dtype="int64"),
      )
      valid_set = (
          np.asarray(np.random.rand(10000, 784), dtype="float32"),
          np.asarray(np.random.rand(10000) * 10, dtype="int64"),
      )
      test_set = (
          np.asarray(np.random.rand(10000, 784), dtype="float32"),
          np.asarray(np.random.rand(10000) * 10, dtype="int64"),
      )
  
      def shared_dataset(data_xy):
          """Function that loads the dataset into shared variables
  
          The reason we store our dataset in shared variables is to allow
          Theano to copy it into the GPU memory (when code is run on GPU).
          Since copying data into the GPU is slow, copying a minibatch every time
          is needed (the default behaviour if the data is not in a shared
          variable) would lead to a large decrease in performance.
          """
          data_x, data_y = data_xy
          shared_x = theano.shared(
              np.asarray(data_x, dtype=theano.config.floatX)
          )
          shared_y = theano.shared(
              np.asarray(data_y, dtype=theano.config.floatX)
          )
          # When storing data on the GPU it has to be stored as floats
          # therefore we will store the labels as ``floatX`` as well
          # (``shared_y`` does exactly that). But during our computations
          # we need them as ints (we use labels as index, and if they are
          # floats it doesn't make sense) therefore instead of returning
          # ``shared_y`` we will have to cast it to int. This little hack
          # lets ous get around this issue
          return shared_x, T.cast(shared_y, "int32")
  
      test_set_x, test_set_y = shared_dataset(test_set)
      valid_set_x, valid_set_y = shared_dataset(valid_set)
      train_set_x, train_set_y = shared_dataset(train_set)
  
      rval = [
          (train_set_x, train_set_y),
          (valid_set_x, valid_set_y),
          (test_set_x, test_set_y),
      ]
      return rval
  
file_path: Theano/theano/tensor/tests/mlp_test.py
imports: from __future__ import absolute_import, print_function, division
  from collections import OrderedDict
  import numpy
  import theano
  import theano.tensor
label_desc: Use image node_id 1 for calling a global function with example usage: gen_data() and returns: rval, shared_x,  T