code: def test_log_performance():
      lengths = np.array([10, 5, 1, 1])
      batch = EpisodeBatch(
          EnvSpec(
              akro.Box(
                  np.array([0.0, 0.0, 0.0]), np.array([1.0, 1.0, 1.0])
              ),
              akro.Box(np.array([-1.0, -1.0]), np.array([0.0, 0.0])),
          ),
          observations=np.ones((sum(lengths), 3), dtype=np.float32),
          last_observations=np.ones(
              (len(lengths), 3), dtype=np.float32
          ),
          actions=np.zeros((sum(lengths), 2), dtype=np.float32),
          rewards=np.array(
              [
                  0.34026529,
                  0.58263177,
                  0.84307509,
                  0.97651095,
                  0.81723901,
                  0.22631398,
                  0.03421301,
                  0.97515046,
                  0.64311832,
                  0.65068933,
                  0.17657714,
                  0.04783857,
                  0.73904013,
                  0.41364329,
                  0.52235551,
                  0.24203526,
                  0.43328910,
              ]
          ),
          step_types=np.array(
              [StepType.FIRST]
              + [StepType.MID] * (lengths[0] - 2)
              + [StepType.TERMINAL]
              + [StepType.FIRST]
              + [StepType.MID] * (lengths[1] - 2)
              + [StepType.TERMINAL]
              + [StepType.FIRST]
              + [StepType.FIRST],
              dtype=StepType,
          ),
          env_infos={
              "success": np.array(
                  [0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1],
                  dtype=bool,
              )
          },
          agent_infos={},
          episode_infos={},
          lengths=lengths,
      )
  
      log_file = tempfile.NamedTemporaryFile()
      csv_output = dowel.CsvOutput(log_file.name)
      logger.add_output(csv_output)
      log_performance(7, batch, 0.8, prefix="test_log_performance")
      logger.log(tabular)
      logger.dump_output_type(dowel.CsvOutput)
      with open(log_file.name, "r") as file:
          rows = list(csv.DictReader(file))
      res = {k: float(r) for (k, r) in rows[0].items()}
      assert res["test_log_performance/Iteration"] == 7
      assert res["test_log_performance/NumEpisodes"] == 4
      assert math.isclose(res["test_log_performance/SuccessRate"], 0.75)
      assert math.isclose(
          res["test_log_performance/TerminationRate"], 0.5
      )
      assert math.isclose(
          res["test_log_performance/AverageDiscountedReturn"],
          1.1131040640673113,
      )
      assert math.isclose(
          res["test_log_performance/AverageReturn"], 2.1659965525
      )
      assert math.isclose(
          res["test_log_performance/StdReturn"], 2.354067152038576
      )
  
imports: import csv
  import math
  import tempfile
  import akro
  import dowel
  from dowel import logger, tabular
  import numpy
  import pytest
  import tensorflow
  import torch
  from garage import _Default, EnvSpec, EpisodeBatch, log_multitask_performance, log_performance, make_optimizer, rollout, StepType
  from garage.envs import GymEnv
  from tests.fixtures import TfGraphTestCase
  from tests.fixtures.envs.dummy import DummyBoxEnv
  from tests.fixtures.policies import DummyPolicy
label_desc: Use image node_id 1 for calling a global function with example usage: test_log_performance() without return types