# tf_agents.eval.metric_utils.eager_compute

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/eval/metric_utils.py#L122-L176) |

Compute metrics using `policy` on the `environment`.

    tf_agents.eval.metric_utils.eager_compute(
        metrics,
        environment,
        policy,
        num_episodes=1,
        train_step=None,
        summary_writer=None,
        summary_prefix='',
        use_function=True
    )

> [!NOTE]
> **Note:** Because placeholders are not compatible with Eager mode we can not use python policies. Because we use tf_policies we need the environment time_steps to be tensors making it easier to use a tf_env for evaluations. Otherwise this method mirrors `compute` directly.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `metrics` | List of metrics to compute. |
| `environment` | tf_environment instance. |
| `policy` | tf_policy instance used to step the environment. |
| `num_episodes` | Number of episodes to compute the metrics over. |
| `train_step` | An optional step to write summaries against. |
| `summary_writer` | An optional writer for generating metric summaries. |
| `summary_prefix` | An optional prefix scope for metric summaries. |
| `use_function` | Option to enable use of [`tf.function`](https://www.tensorflow.org/api_docs/python/tf/function) when collecting the metrics. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A dictionary of results {metric_name: metric_value} ||

<br />