docstr: Reward at each step is a linear function of present state and action.
  However, we can only observe aggregated reward at the last step
  
  This model will fail to learn when ground-truth reward is a function of
  multiple steps' states and actions.
docstr_tok: ["Reward","at","each","step","is","a","linear","function","of","present","state","and","action",".","However",",","we","can","only","observe","aggregated","reward","at","the","last","step","This","model","will","fail","to","learn","when","ground-truth","reward","is","a","function","of","multiple","steps","'","states","and","actions","."]
code: def test_single_step_parametric_binary_reward(self):
      """
      Reward at each step is a linear function of present state and action.
      However, we can only observe aggregated reward at the last step
  
      This model will fail to learn when ground-truth reward is a function of
      multiple steps' states and actions.
      """
      state_dim = 10
      action_dim = 2
      seq_len = 5
      batch_size = 512
      num_batches = 5000
      sizes = [256, 128]
      activations = ["relu", "relu"]
      last_layer_activation = "sigmoid"
      reward_net = SyntheticRewardNet(
          SingleStepSyntheticRewardNet(
              state_dim=state_dim,
              action_dim=action_dim,
              sizes=sizes,
              activations=activations,
              last_layer_activation=last_layer_activation,
          )
      )
      optimizer = Optimizer__Union(Adam=classes["Adam"]())
      trainer = RewardNetTrainer(
          reward_net, optimizer, loss_type=LossFunction.BCELoss
      )
      trainer.set_reporter(
          RewardNetworkReporter(
              trainer.loss_type,
              str(reward_net),
          )
      )
      weight, data = create_data(
          state_dim,
          action_dim,
          seq_len,
          batch_size,
          num_batches,
          binary_reward=True,
      )
      avg_eval_loss = train_and_eval(trainer, data)
      return avg_eval_loss
  
imports: import logging
  import unittest
  import pytorch_lightning
  import torch
  from reagent.core import parameters, types
  from reagent.models.synthetic_reward import NGramConvolutionalNetwork, NGramFullyConnectedNetwork, SequenceSyntheticRewardNet, SingleStepSyntheticRewardNet, SyntheticRewardNet, TransformerSyntheticRewardNet
  from reagent.optimizer.union import classes, Optimizer__Union
  from reagent.reporting.reward_network_reporter import RewardNetworkReporter
  from reagent.training import RewardNetTrainer
  from reagent.training.reward_network_trainer import LossFunction
  from torch.utils.data import DataLoader
label_desc: Use image node_id 5 for calling the TestSyntheticRewardTraining obj's underlying member method code with example usage: obj.test_single_step_parametric_binary_reward() and returns: avg_eval_loss