docstr: Reward at each step is a linear function of states and actions in a
  context window around the step.
  
  However, we can only observe aggregated reward at the last step
docstr_tok: ["Reward","at","each","step","is","a","linear","function","of","states","and","actions","in","a","context","window","around","the","step",".","However",",","we","can","only","observe","aggregated","reward","at","the","last","step"]
code: def test_ngram_fc_parametric_reward(self):
      """
      Reward at each step is a linear function of states and actions in a
      context window around the step.
  
      However, we can only observe aggregated reward at the last step
      """
      state_dim = 10
      action_dim = 2
      seq_len = 5
      batch_size = 512
      num_batches = 10000
      sizes = [256, 128]
      activations = ["relu", "relu"]
      last_layer_activation = "linear"
      reward_net = SyntheticRewardNet(
          NGramFullyConnectedNetwork(
              state_dim=state_dim,
              action_dim=action_dim,
              sizes=sizes,
              activations=activations,
              last_layer_activation=last_layer_activation,
              context_size=3,
          )
      )
      optimizer = Optimizer__Union(Adam=classes["Adam"]())
      trainer = RewardNetTrainer(reward_net, optimizer)
      trainer.set_reporter(
          RewardNetworkReporter(
              trainer.loss_type,
              str(reward_net),
          )
      )
      weight, data = create_sequence_data(
          state_dim, action_dim, seq_len, batch_size, num_batches
      )
      threshold = 0.2
      avg_eval_loss = train_and_eval(trainer, data)
      assert avg_eval_loss < threshold
  
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 6 for calling the TestSyntheticRewardTraining obj's underlying member method code with example usage: obj.test_ngram_fc_parametric_reward() without return types