code: def get_reward_and_done(board):
      """Given a representation of the board, returns reward and done."""
      # Returns (reward, done) where:
      # reward: -1 means lost, +1 means win, 0 means draw or continuing.
      # done: True if the game is over, i.e. someone won or it is a draw.
  
      # Sum all rows ...
      all_sums = [np.sum(board[i, :]) for i in range(3)]
      # ... all columns
      all_sums.extend([np.sum(board[:, i]) for i in range(3)])
      # and both diagonals.
      all_sums.append(np.sum([board[i, i] for i in range(3)]))
      all_sums.append(np.sum([board[i, 2 - i] for i in range(3)]))
  
      if -3 in all_sums:
          return -1, True
  
      if 3 in all_sums:
          return 1, True
  
      done = True
      if get_open_spaces(board):
          done = False
  
      return 0, done
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import gym
  from gym import spaces
  from gym.utils import seeding
  import numpy
  from tensor2tensor.data_generators import problem
  from tensor2tensor.layers import modalities
  from tensor2tensor.rl import gym_utils
label_desc: Use image node_id 4 for calling a global function with example usage: get_reward_and_done(board) and returns: int,  done, unknown,  True, int,  True