class_docstr: `Bert_score Evaluating Text Generation`_ for measuring text similarity.
  
  BERT leverages the pre-trained contextual embeddings from BERT and matches words in candidate and reference
  sentences by cosine similarity. It has been shown to correlate with human judgment on sentence-level and
  system-level evaluation. Moreover, BERTScore computes precision, recall, and F1 measure, which can be useful for
  evaluating different language generation tasks. This implementation follows the original implementation from
  `BERT_score`_.
  
  As input to ``forward`` and ``update`` the metric accepts the following input:
  
  - ``preds`` (:class:`~List`): An iterable of predicted sentences
  - ``target`` (:class:`~List`): An iterable of reference sentences
  
  As output of ``forward`` and ``compute`` the metric returns the following output:
  
  - ``score`` (:class:`~Dict`): A dictionary containing the keys ``precision``, ``recall`` and ``f1`` with
    corresponding values
  
  Args:
      preds: An iterable of predicted sentences.
      target: An iterable of target sentences.
      model_type: A name or a model path used to load ``transformers`` pretrained model.
      num_layers: A layer of representation to use.
      all_layers:
          An indication of whether the representation from all model's layers should be used.
          If ``all_layers=True``, the argument ``num_layers`` is ignored.
      model:  A user's own model. Must be of `torch.nn.Module` instance.
      user_tokenizer:
          A user's own tokenizer used with the own model. This must be an instance with the ``__call__`` method.
          This method must take an iterable of sentences (`List[str]`) and must return a python dictionary
          containing `"input_ids"` and `"attention_mask"` represented by :class:`~torch.Tensor`.
          It is up to the user's model of whether `"input_ids"` is a :class:`~torch.Tensor` of input ids or embedding
          vectors. This tokenizer must prepend an equivalent of ``[CLS]`` token and append an equivalent of ``[SEP]``
          token as ``transformers`` tokenizer does.
      user_forward_fn:
          A user's own forward function used in a combination with ``user_model``. This function must take
          ``user_model`` and a python dictionary of containing ``"input_ids"`` and ``"attention_mask"`` represented
          by :class:`~torch.Tensor` as an input and return the model's output represented by the single
          :class:`~torch.Tensor`.
      verbose: An indication of whether a progress bar to be displayed during the embeddings' calculation.
      idf: An indication whether normalization using inverse document frequencies should be used.
      device: A device to be used for calculation.
      max_length: A maximum length of input sequences. Sequences longer than ``max_length`` are to be trimmed.
      batch_size: A batch size used for model processing.
      num_threads: A number of threads to use for a dataloader.
      return_hash: An indication of whether the correspodning ``hash_code`` should be returned.
      lang: A language of input sentences.
      rescale_with_baseline:
          An indication of whether bertscore should be rescaled with a pre-computed baseline.
          When a pretrained model from ``transformers`` model is used, the corresponding baseline is downloaded
          from the original ``bert-score`` package from `BERT_score`_ if available.
          In other cases, please specify a path to the baseline csv/tsv file, which must follow the formatting
          of the files from `BERT_score`_.
      baseline_path: A path to the user's own local csv/tsv file with the baseline scale.
      baseline_url: A url path to the user's own  csv/tsv file with the baseline scale.
      kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.
  
  Example:
      >>> from pprint import pprint
      >>> from torchmetrics.text.bert import BERTScore
      >>> preds = ["hello there", "general kenobi"]
      >>> target = ["hello there", "master kenobi"]
      >>> bertscore = BERTScore()
      >>> pprint(bertscore(preds, target))
      {'f1': tensor([1.0000, 0.9961]), 'precision': tensor([1.0000, 0.9961]), 'recall': tensor([1.0000, 0.9961])}
class_docstr_tok: ["`","Bert_score","Evaluating","Text","Generation","`","_","for","measuring","text","similarity",".","BERT","leverages","the","pre-trained","contextual","embeddings","from","BERT","and","matches","words","in","candidate","and","reference","sentences","by","cosine","similarity",".","It","has","been","shown","to","correlate","with","human","judgment","on","sentence-level","and","system-level","evaluation",".","Moreover",",","BERTScore","computes","precision",",","recall",",","and","F1","measure",",","which","can","be","useful","for","evaluating","different","language","generation","tasks",".","This","implementation","follows","the","original","implementation","from","`","BERT_score","`","_",".","As","input","to","``","forward","``","and","``","update","``","the","metric","accepts","the","following","input",":","-","``","preds","``","(",":","class",":","`","~List","`",")",":","An","iterable","of","predicted","sentences","-","``","target","``","(",":","class",":","`","~List","`",")",":","An","iterable","of","reference","sentences","As","output","of","``","forward","``","and","``","compute","``","the","metric","returns","the","following","output",":","-","``","score","``","(",":","class",":","`","~Dict","`",")",":","A","dictionary","containing","the","keys","``","precision","``",",","``","recall","``","and","``","f1","``","with","corresponding","values","Args",":","preds",":","An","iterable","of","predicted","sentences",".","target",":","An","iterable","of","target","sentences",".","model_type",":","A","name","or","a","model","path","used","to","load","``","transformers","``","pretrained","model",".","num_layers",":","A","layer","of","representation","to","use",".","all_layers",":","An","indication","of","whether","the","representation","from","all","model","'s","layers","should","be","used",".","If","``","all_layers=True","``",",","the","argument","``","num_layers","``","is","ignored",".","model",":","A","user","'s","own","model",".","Must","be","of","`","torch.nn.Module","`","instance",".","user_tokenizer",":","A","user","'s","own","tokenizer","used","with","the","own","model",".","This","must","be","an","instance","with","the","``","__call__","``","method",".","This","method","must","take","an","iterable","of","sentences","(","`","List","[","str","]","`",")","and","must","return","a","python","dictionary","containing","`","``","input_ids","''","`","and","`","``","attention_mask","''","`","represented","by",":","class",":","`","~torch.Tensor","`",".","It","is","up","to","the","user","'s","model","of","whether","`","``","input_ids","''","`","is","a",":","class",":","`","~torch.Tensor","`","of","input","ids","or","embedding","vectors",".","This","tokenizer","must","prepend","an","equivalent","of","``","[","CLS","]","``","token","and","append","an","equivalent","of","``","[","SEP","]","``","token","as","``","transformers","``","tokenizer","does",".","user_forward_fn",":","A","user","'s","own","forward","function","used","in","a","combination","with","``","user_model","``",".","This","function","must","take","``","user_model","``","and","a","python","dictionary","of","containing","``","``","input_ids","''","``","and","``","``","attention_mask","''","``","represented","by",":","class",":","`","~torch.Tensor","`","as","an","input","and","return","the","model","'s","output","represented","by","the","single",":","class",":","`","~torch.Tensor","`",".","verbose",":","An","indication","of","whether","a","progress","bar","to","be","displayed","during","the","embeddings","'","calculation",".","idf",":","An","indication","whether","normalization","using","inverse","document","frequencies","should","be","used",".","device",":","A","device","to","be","used","for","calculation",".","max_length",":","A","maximum","length","of","input","sequences",".","Sequences","longer","than","``","max_length","``","are","to","be","trimmed",".","batch_size",":","A","batch","size","used","for","model","processing",".","num_threads",":","A","number","of","threads","to","use","for","a","dataloader",".","return_hash",":","An","indication","of","whether","the","correspodning","``","hash_code","``","should","be","returned",".","lang",":","A","language","of","input","sentences",".","rescale_with_baseline",":","An","indication","of","whether","bertscore","should","be","rescaled","with","a","pre-computed","baseline",".","When","a","pretrained","model","from","``","transformers","``","model","is","used",",","the","corresponding","baseline","is","downloaded","from","the","original","``","bert-score","``","package","from","`","BERT_score","`","_","if","available",".","In","other","cases",",","please","specify","a","path","to","the","baseline","csv\/tsv","file",",","which","must","follow","the","formatting","of","the","files","from","`","BERT_score","`","_",".","baseline_path",":","A","path","to","the","user","'s","own","local","csv\/tsv","file","with","the","baseline","scale",".","baseline_url",":","A","url","path","to","the","user","'s","own","csv\/tsv","file","with","the","baseline","scale",".","kwargs",":","Additional","keyword","arguments",",","see",":","ref",":","`","Metric","kwargs","`","for","more","info",".","Example",":",">",">",">","from","pprint","import","pprint",">",">",">","from","torchmetrics.text.bert","import","BERTScore",">",">",">","preds","=","[","``","hello","there","''",",","``","general","kenobi","''","]",">",">",">","target","=","[","``","hello","there","''",",","``","master","kenobi","''","]",">",">",">","bertscore","=","BERTScore","(",")",">",">",">","pprint","(","bertscore","(","preds",",","target",")",")","{","'f1","'",":","tensor","(","[","1.0000",",","0.9961","]",")",",","'precision","'",":","tensor","(","[","1.0000",",","0.9961","]",")",",","'recall","'",":","tensor","(","[","1.0000",",","0.9961","]",")","}"]
docstr: Store predictions/references for computing BERT scores.
  
  It is necessary to store sentences in a tokenized form to ensure the DDP mode working.
docstr_tok: ["Store","predictions\/references","for","computing","BERT","scores",".","It","is","necessary","to","store","sentences","in","a","tokenized","form","to","ensure","the","DDP","mode","working","."]
code: def update(
      self,
      preds: Union[str, Sequence[str]],
      target: Union[str, Sequence[str]],
  ) -> None:
      """Store predictions/references for computing BERT scores.
  
      It is necessary to store sentences in a tokenized form to ensure the DDP mode working.
  
      """
      if not isinstance(preds, list):
          preds = list(preds)
      if not isinstance(target, list):
          target = list(target)
  
      preds_dict, _ = _preprocess_text(
          preds,
          self.tokenizer,
          self.max_length,
          truncation=False,
          sort_according_length=False,
          own_tokenizer=self.user_tokenizer,
      )
      target_dict, _ = _preprocess_text(
          target,
          self.tokenizer,
          self.max_length,
          truncation=False,
          sort_according_length=False,
          own_tokenizer=self.user_tokenizer,
      )
  
      self.preds_input_ids.append(preds_dict["input_ids"])
      self.preds_attention_mask.append(preds_dict["attention_mask"])
      self.target_input_ids.append(target_dict["input_ids"])
      self.target_attention_mask.append(target_dict["attention_mask"])
  
file_path: torchmetrics/src/torchmetrics/text/bert.py
imports: from typing import Any, Callable, Dict, List, Optional, Sequence, Union
  import torch
  from torch import Tensor
  from torch.nn import Module
  from torchmetrics.functional.text.bert import bert_score
  from torchmetrics.functional.text.helper_embedding_metric import _preprocess_text
  from torchmetrics.metric import Metric
  from torchmetrics.utilities import rank_zero_warn
  from torchmetrics.utilities.checks import _SKIP_SLOW_DOCTEST, _try_proceed_with_timeout
  from torchmetrics.utilities.data import dim_zero_cat
  from torchmetrics.utilities.imports import _MATPLOTLIB_AVAILABLE, _TRANSFORMERS_GREATER_EQUAL_4_4
  from torchmetrics.utilities.plot import _AX_TYPE, _PLOT_OUT_TYPE
label_desc: Use image node_id 2 for calling the BERTScore obj's underlying member method code with example usage: obj.update(preds, target) without return types