# Trainer class and compute\_metrics

**URL:** <https://discuss.huggingface.co/t/trainer-class-and-compute-metrics/6023>\
**Category:** 🤗Transformers\
**Created:** [May 6, 2021, 9:04am UTC](https://discuss.huggingface.co/t/trainer-class-and-compute-metrics/6023 "2021-05-06T09:04:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hannibal046](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@Hannibal046](https://discuss.huggingface.co/u/Hannibal046)\
**Post date:** [May 6, 2021, 9:04am UTC](https://discuss.huggingface.co/t/trainer-class-and-compute-metrics/6023/1 "2021-05-06T09:04:28Z")

</div>

Hello!  
I am doing summarization tasks and when I am looking through the example of summarization[link](https://github.com/huggingface/transformers/blob/master/examples/pytorch/summarization/run_summarization.py). In `compute_metrics` function. The tokenizer is defined in the same namespace before. But if I want to another scripts to store `compute_metrics` function. How do I modify the function when it comes to tokenizer, since I pass it to Trainer. I just do not like everything in the `main function`.

Thanks
