code: def create_network(available_actions_count):
      # Create the input variables
      s1 = tensor.tensor4("State")
      a = tensor.vector("Action", dtype="int32")
      q2 = tensor.vector("Q2")
      r = tensor.vector("Reward")
      isterminal = tensor.vector("IsTerminal", dtype="int8")
  
      # Create the input layer of the network.
      dqn = InputLayer(
          shape=[None, 1, resolution[0], resolution[1]], input_var=s1
      )
  
      # Add 2 convolutional layers with ReLu activation
      dqn = Conv2DLayer(
          dqn,
          num_filters=8,
          filter_size=[6, 6],
          nonlinearity=rectify,
          W=HeUniform("relu"),
          b=Constant(0.1),
          stride=3,
      )
      dqn = Conv2DLayer(
          dqn,
          num_filters=8,
          filter_size=[3, 3],
          nonlinearity=rectify,
          W=HeUniform("relu"),
          b=Constant(0.1),
          stride=2,
      )
  
      # Add a single fully-connected layer.
      dqn = DenseLayer(
          dqn,
          num_units=128,
          nonlinearity=rectify,
          W=HeUniform("relu"),
          b=Constant(0.1),
      )
  
      # Add the output layer (also fully-connected).
      # (no nonlinearity as it is for approximating an arbitrary real function)
      dqn = DenseLayer(
          dqn, num_units=available_actions_count, nonlinearity=None
      )
  
      # Define the loss function
      q = get_output(dqn)
      # target differs from q only for the selected action. The following means:
      # target_Q(s,a) = r + gamma * max Q(s2,_) if isterminal else r
      target_q = tensor.set_subtensor(
          q[tensor.arange(q.shape[0]), a],
          r + discount_factor * (1 - isterminal) * q2,
      )
      loss = squared_error(q, target_q).mean()
  
      # Update the parameters according to the computed gradient using RMSProp.
      params = get_all_params(dqn, trainable=True)
      updates = rmsprop(loss, params, learning_rate)
  
      # Compile the theano functions
      print("Compiling the network ...")
      function_learn = theano.function(
          [s1, q2, a, r, isterminal],
          loss,
          updates=updates,
          name="learn_fn",
      )
      function_get_q_values = theano.function([s1], q, name="eval_fn")
      function_get_best_action = theano.function(
          [s1], tensor.argmax(q), name="test_fn"
      )
      print("Network compiled.")
  
      def simple_get_best_action(state):
          return function_get_best_action(
              state.reshape([1, 1, resolution[0], resolution[1]])
          )
  
      # Returns Theano objects for the net and functions.
      return (
          dqn,
          function_learn,
          function_get_q_values,
          simple_get_best_action,
      )
  
imports: import itertools
  import pickle
  from random import randint, random, sample
  from time import sleep, time
  import numpy
  import skimage.color
  import skimage.transform
  import theano
  from lasagne.init import Constant, HeUniform
  from lasagne.layers import Conv2DLayer, DenseLayer, InputLayer, get_all_param_values, get_all_params, get_output, set_all_param_values
  from lasagne.nonlinearities import rectify
  from lasagne.objectives import squared_error
  from lasagne.updates import rmsprop
  from theano import tensor
  from tqdm import trange
  from vizdoom import DoomGame, Mode, ScreenFormat, ScreenResolution, os, vzd
label_desc: Use image node_id 2 for calling a global function with example usage: create_network(available_actions_count) and returns: dqn,  function_learn,  function_get_q_values,  simple_get_best_action, function_get_best_action