prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  sim_policy not working
  Hi, 
  I just found that sim_policy.py cannot work. 
  data that read from "params.pkl" does not include the key of "policy"
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `examples/sim_policy.py`
  Content:
  ```
  1 #!/usr/bin/env python3
  2 
  3 import argparse
  4 
  5 import joblib
  6 import tensorflow as tf
  7 
  8 from garage.misc.console import query_yes_no
  9 from garage.sampler.utils import rollout
  10 
  11 if __name__ == "__main__":
  12 
  13     parser = argparse.ArgumentParser()
  14     parser.add_argument('file', type=str, help='path to the snapshot file')
  15     parser.add_argument(
  16         '--max_path_length',
  17         type=int,
  18         default=1000,
  19         help='Max length of rollout')
  20     parser.add_argument('--speedup', type=float, default=1, help='Speedup')
  21     args = parser.parse_args()
  22 
  23     # If the snapshot file use tensorflow, do:
  24     # import tensorflow as tf
  25     # with tf.Session():
  26     #     [rest of the code]
  27     with tf.Session() as sess:
  28         data = joblib.load(args.file)
  29         policy = data['policy']
  30         env = data['env']
  31         while True:
  32             path = rollout(
  33                 env,
  34                 policy,
  35                 max_path_length=args.max_path_length,
  36                 animated=True,
  37                 speedup=args.speedup)
  38             if not query_yes_no('Continue simulation?'):
  39                 break
  40
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/examples/sim_policy.py b/examples/sim_policy.py
  --- a/examples/sim_policy.py
  +++ b/examples/sim_policy.py
  @@ -8,7 +8,7 @@
   from garage.misc.console import query_yes_no
   from garage.sampler.utils import rollout
   
  -if __name__ == "__main__":
  +if __name__ == '__main__':
   
       parser = argparse.ArgumentParser()
       parser.add_argument('file', type=str, help='path to the snapshot file')
  @@ -26,7 +26,7 @@
       #     [rest of the code]
       with tf.Session() as sess:
           data = joblib.load(args.file)
  -        policy = data['policy']
  +        policy = data['algo'].policy
           env = data['env']
           while True:
               path = rollout(
  
verification_info: {"golden_diff": "diff --git a/examples/sim_policy.py b/examples/sim_policy.py\n--- a/examples/sim_policy.py\n+++ b/examples/sim_policy.py\n@@ -8,7 +8,7 @@\n from garage.misc.console import query_yes_no\n from garage.sampler.utils import rollout\n \n-if __name__ == \"__main__\":\n+if __name__ == '__main__':\n \n     parser = argparse.ArgumentParser()\n     parser.add_argument('file', type=str, help='path to the snapshot file')\n@@ -26,7 +26,7 @@\n     #     [rest of the code]\n     with tf.Session() as sess:\n         data = joblib.load(args.file)\n-        policy = data['policy']\n+        policy = data['algo'].policy\n         env = data['env']\n         while True:\n             path = rollout(\n", "issue": "sim_policy not working\nHi, \r\nI just found that sim_policy.py cannot work. \r\ndata that read from \"params.pkl\" does not include the key of \"policy\"\n", "before_files": [{"content": "#!/usr/bin/env python3\n\nimport argparse\n\nimport joblib\nimport tensorflow as tf\n\nfrom garage.misc.console import query_yes_no\nfrom garage.sampler.utils import rollout\n\nif __name__ == \"__main__\":\n\n    parser = argparse.ArgumentParser()\n    parser.add_argument('file', type=str, help='path to the snapshot file')\n    parser.add_argument(\n        '--max_path_length',\n        type=int,\n        default=1000,\n        help='Max length of rollout')\n    parser.add_argument('--speedup', type=float, default=1, help='Speedup')\n    args = parser.parse_args()\n\n    # If the snapshot file use tensorflow, do:\n    # import tensorflow as tf\n    # with tf.Session():\n    #     [rest of the code]\n    with tf.Session() as sess:\n        data = joblib.load(args.file)\n        policy = data['policy']\n        env = data['env']\n        while True:\n            path = rollout(\n                env,\n                policy,\n                max_path_length=args.max_path_length,\n                animated=True,\n                speedup=args.speedup)\n            if not query_yes_no('Continue simulation?'):\n                break\n", "path": "examples/sim_policy.py"}], "after_files": [{"content": "#!/usr/bin/env python3\n\nimport argparse\n\nimport joblib\nimport tensorflow as tf\n\nfrom garage.misc.console import query_yes_no\nfrom garage.sampler.utils import rollout\n\nif __name__ == '__main__':\n\n    parser = argparse.ArgumentParser()\n    parser.add_argument('file', type=str, help='path to the snapshot file')\n    parser.add_argument(\n        '--max_path_length',\n        type=int,\n        default=1000,\n        help='Max length of rollout')\n    parser.add_argument('--speedup', type=float, default=1, help='Speedup')\n    args = parser.parse_args()\n\n    # If the snapshot file use tensorflow, do:\n    # import tensorflow as tf\n    # with tf.Session():\n    #     [rest of the code]\n    with tf.Session() as sess:\n        data = joblib.load(args.file)\n        policy = data['algo'].policy\n        env = data['env']\n        while True:\n            path = rollout(\n                env,\n                policy,\n                max_path_length=args.max_path_length,\n                animated=True,\n                speedup=args.speedup)\n            if not query_yes_no('Continue simulation?'):\n                break\n", "path": "examples/sim_policy.py"}]}