code: def training_samples(network, memory, gamma=0.9):
      data = np.array(
          memory,
          dtype=[
              ("state", np.ndarray),
              ("action", np.int),
              ("reward", np.int),
              ("done", np.bool),
              ("new_state", np.ndarray),
          ],
      )
  
      state = np.array(data["state"].tolist())
      new_state = np.array(data["new_state"].tolist())
  
      # Note: Calculating Q for all states at once is much faster
      # that do it per each sample separately
      Q = network.predict(state)
      new_Q = network.predict(new_state)
      max_Q = np.max(new_Q, axis=1)
  
      n_samples = len(memory)
      row_index = np.arange(n_samples)
      column_index = data["action"]
  
      Q[(row_index, column_index)] = np.where(
          data["done"], data["reward"], data["reward"] + gamma * max_Q
      )
  
      return state, Q
  
file_path: neupy/examples/reinforcement_learning/rl_cartpole.py
imports: import os
  import random
  import argparse
  from collections import deque
  import gym
  import numpy
  from neupy import layers, algorithms, utils, storage
label_desc: Use image node_id 1 for calling a global function with example usage: training_samples(network, memory, gamma) and returns: state,  Q