code: def exact_match_reward(responses, answers=None):
      """Reward if generated response contains correct answer."""
      rewards = []
      pattern = r"Result\s*=\s*(-?\d+(?:\.\d+)?)\s*<submit>"  # generated by chatGPT
      for response, answer in zip(responses, answers):
          reward = 0.0
          try:
              predicted_number = None
              match_pattern = re.findall(pattern, response)
              if match_pattern:
                  predicted_number = float(match_pattern[0])
              if predicted_number is not None:
                  if np.abs((predicted_number - float(answer))) < 0.1:
                      reward += 1.0
          except:  # noqa
              pass
          rewards.append(torch.tensor(reward))
      return rewards
  
file_path: trl/examples/research_projects/tools/python_interpreter.py
imports: import os
  import re
  from dataclasses import dataclass, field
  from typing import Optional
  import numpy
  import torch
  from datasets import load_dataset
  from peft import LoraConfig
  from transformers import AutoTokenizer, HfArgumentParser, load_tool
  from trl import AutoModelForCausalLMWithValueHead, PPOConfig, PPOTrainer, TextEnvironment
label_desc: Use image node_id 1 for calling a global function with example usage: exact_match_reward(responses, answers) and returns: rewards