class_docstr: Calculate `chrf score`_ of machine translated text with one or more references.
  
  This implementation supports both ChrF score computation introduced in `chrF score`_ and `chrF++ score`_ introduced
  in `chrF++ score`_. This implementation follows the implementations from https://github.com/m-popovic/chrF and
  https://github.com/mjpost/sacrebleu/blob/master/sacrebleu/metrics/chrf.py.
  
  As input to ``forward`` and ``update`` the metric accepts the following input:
  
  - ``preds`` (:class:`~Sequence`): An iterable of hypothesis corpus
  - ``target`` (:class:`~Sequence`): An iterable of iterables of reference corpus
  
  As output of ``forward`` and ``compute`` the metric returns the following output:
  
  - ``chrf`` (:class:`~torch.Tensor`): If `return_sentence_level_score=True` return a list of sentence-level
    chrF/chrF++ scores, else return a corpus-level chrF/chrF++ score
  
  Args:
      n_char_order: A character n-gram order. If ``n_char_order=6``, the metrics refers to the official chrF/chrF++.
      n_word_order: A word n-gram order. If ``n_word_order=2``, the metric refers to the official chrF++.
          If ``n_word_order=0``, the metric is equivalent to the original ChrF.
      beta: parameter determining an importance of recall w.r.t. precision. If ``beta=1``, their importance is equal.
      lowercase: An indication whether to enable case-insensitivity.
      whitespace: An indication whether keep whitespaces during n-gram extraction.
      return_sentence_level_score: An indication whether a sentence-level chrF/chrF++ score to be returned.
      kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.
  
  Raises:
      ValueError:
          If ``n_char_order`` is not an integer greater than or equal to 1.
      ValueError:
          If ``n_word_order`` is not an integer greater than or equal to 0.
      ValueError:
          If ``beta`` is smaller than 0.
  
  Example:
      >>> from torchmetrics.text import CHRFScore
      >>> preds = ['the cat is on the mat']
      >>> target = [['there is a cat on the mat', 'a cat is on the mat']]
      >>> chrf = CHRFScore()
      >>> chrf(preds, target)
      tensor(0.8640)
class_docstr_tok: ["Calculate","`","chrf","score","`","_","of","machine","translated","text","with","one","or","more","references",".","This","implementation","supports","both","ChrF","score","computation","introduced","in","`","chrF","score","`","_","and","`","chrF++","score","`","_","introduced","in","`","chrF++","score","`","_",".","This","implementation","follows","the","implementations","from","https",":","\/\/github.com\/m-popovic\/chrF","and","https",":","\/\/github.com\/mjpost\/sacrebleu\/blob\/master\/sacrebleu\/metrics\/chrf.py",".","As","input","to","``","forward","``","and","``","update","``","the","metric","accepts","the","following","input",":","-","``","preds","``","(",":","class",":","`","~Sequence","`",")",":","An","iterable","of","hypothesis","corpus","-","``","target","``","(",":","class",":","`","~Sequence","`",")",":","An","iterable","of","iterables","of","reference","corpus","As","output","of","``","forward","``","and","``","compute","``","the","metric","returns","the","following","output",":","-","``","chrf","``","(",":","class",":","`","~torch.Tensor","`",")",":","If","`","return_sentence_level_score=True","`","return","a","list","of","sentence-level","chrF\/chrF++","scores",",","else","return","a","corpus-level","chrF\/chrF++","score","Args",":","n_char_order",":","A","character","n-gram","order",".","If","``","n_char_order=6","``",",","the","metrics","refers","to","the","official","chrF\/chrF++",".","n_word_order",":","A","word","n-gram","order",".","If","``","n_word_order=2","``",",","the","metric","refers","to","the","official","chrF++",".","If","``","n_word_order=0","``",",","the","metric","is","equivalent","to","the","original","ChrF",".","beta",":","parameter","determining","an","importance","of","recall","w.r.t",".","precision",".","If","``","beta=1","``",",","their","importance","is","equal",".","lowercase",":","An","indication","whether","to","enable","case-insensitivity",".","whitespace",":","An","indication","whether","keep","whitespaces","during","n-gram","extraction",".","return_sentence_level_score",":","An","indication","whether","a","sentence-level","chrF\/chrF++","score","to","be","returned",".","kwargs",":","Additional","keyword","arguments",",","see",":","ref",":","`","Metric","kwargs","`","for","more","info",".","Raises",":","ValueError",":","If","``","n_char_order","``","is","not","an","integer","greater","than","or","equal","to","1",".","ValueError",":","If","``","n_word_order","``","is","not","an","integer","greater","than","or","equal","to","0",".","ValueError",":","If","``","beta","``","is","smaller","than","0",".","Example",":",">",">",">","from","torchmetrics.text","import","CHRFScore",">",">",">","preds","=","[","'the","cat","is","on","the","mat","'","]",">",">",">","target","=","[","[","'there","is","a","cat","on","the","mat","'",",","'","a","cat","is","on","the","mat","'","]","]",">",">",">","chrf","=","CHRFScore","(",")",">",">",">","chrf","(","preds",",","target",")","tensor","(","0.8640",")"]
docstr: Update global metric states based on the n-gram dictionaries calculated on the current batch.
docstr_tok: ["Update","global","metric","states","based","on","the","n-gram","dictionaries","calculated","on","the","current","batch","."]
code: def _update_states_from_dicts(
      self, n_grams_dicts_tuple: _DICT_STATES_TYPES
  ) -> None:
      """Update global metric states based on the n-gram dictionaries calculated on the current batch."""
      n_grams_dicts = dict(zip(_DICT_STATES_NAMES, n_grams_dicts_tuple))
      for (
          n_gram_level,
          n_gram_order,
      ), text in self._get_text_n_gram_iterator():
          for n in range(1, n_gram_order + 1):
              dict_name = self._get_dict_name(text, n_gram_level)
              state_name = self._get_state_name(text, n_gram_level, n)
  
              setattr(self, state_name, n_grams_dicts[dict_name][n])
  
file_path: torchmetrics/src/torchmetrics/text/chrf.py
imports: import itertools
  from typing import Any, Dict, Iterator, List, Optional, Sequence, Tuple, Union
  import torch
  from torch import Tensor, tensor
  from torchmetrics import Metric
  from torchmetrics.functional.text.chrf import _chrf_score_compute, _chrf_score_update, _prepare_n_grams_dicts
  from torchmetrics.utilities.imports import _MATPLOTLIB_AVAILABLE
  from torchmetrics.utilities.plot import _AX_TYPE, _PLOT_OUT_TYPE
label_desc: Use image node_id 5 for calling the CHRFScore obj's underlying member method code with example usage: obj._update_states_from_dicts(n_grams_dicts_tuple) without return types