class_docstr: Class to address backward compatibility issues with older ParlAI models.
class_docstr_tok: ["Class","to","address","backward","compatibility","issues","with","older","ParlAI","models","."]
code: def serialize_bot_message(bot_message):
      if "metrics" in bot_message:
          metric_report = bot_message["metrics"]
          bot_message["metrics"] = {
              k: v.value() if isinstance(v, Metric) else v
              for k, v in metric_report.items()
          }
      return bot_message
  
imports: import base64
  import datetime
  import json
  import os
  import random
  import threading
  import time
  import unittest
  from io import BytesIO
  from typing import Any, Dict, Optional, Tuple
  from PIL import Image
  from parlai.core.message import Message
  from parlai.core.metrics import Metric
  from parlai.core.params import ParlaiParser
  from parlai.core.loader import load_task_module
  from parlai.crowdsourcing.utils.tests import AbstractParlAIChatTest
  from parlai.tasks.blended_skill_talk.agents import ContextGenerator
label_desc: Use image node_id 3 for calling the Compatibility obj's underlying member method code with example usage: obj.serialize_bot_message(bot_message) and returns: bot_message