class_docstr: Using `Turn a Metric into a Bootstrapped`_.
  
  That can automate the process of getting confidence intervals for metric values. This wrapper
  class basically keeps multiple copies of the same base metric in memory and whenever ``update`` or
  ``forward`` is called, all input tensors are resampled (with replacement) along the first dimension.
  
  Args:
      base_metric: base metric class to wrap
      num_bootstraps: number of copies to make of the base metric for bootstrapping
      mean: if ``True`` return the mean of the bootstraps
      std: if ``True`` return the standard deviation of the bootstraps
      quantile: if given, returns the quantile of the bootstraps. Can only be used with pytorch version 1.6 or higher
      raw: if ``True``, return all bootstrapped values
      sampling_strategy:
          Determines how to produce bootstrapped samplings. Either ``'poisson'`` or ``multinomial``.
          If ``'possion'`` is chosen, the number of times each sample will be included in the bootstrap
          will be given by :math:`n\sim Poisson(\lambda=1)`, which approximates the true bootstrap distribution
          when the number of samples is large. If ``'multinomial'`` is chosen, we will apply true bootstrapping
          at the batch level to approximate bootstrapping over the hole dataset.
      kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.
  
  Example::
      >>> from pprint import pprint
      >>> from torchmetrics.wrappers import BootStrapper
      >>> from torchmetrics.classification import MulticlassAccuracy
      >>> _ = torch.manual_seed(123)
      >>> base_metric = MulticlassAccuracy(num_classes=5, average='micro')
      >>> bootstrap = BootStrapper(base_metric, num_bootstraps=20)
      >>> bootstrap.update(torch.randint(5, (20,)), torch.randint(5, (20,)))
      >>> output = bootstrap.compute()
      >>> pprint(output)
      {'mean': tensor(0.2205), 'std': tensor(0.0859)}
class_docstr_tok: ["Using","`","Turn","a","Metric","into","a","Bootstrapped","`","_",".","That","can","automate","the","process","of","getting","confidence","intervals","for","metric","values",".","This","wrapper","class","basically","keeps","multiple","copies","of","the","same","base","metric","in","memory","and","whenever","``","update","``","or","``","forward","``","is","called",",","all","input","tensors","are","resampled","(","with","replacement",")","along","the","first","dimension",".","Args",":","base_metric",":","base","metric","class","to","wrap","num_bootstraps",":","number","of","copies","to","make","of","the","base","metric","for","bootstrapping","mean",":","if","``","True","``","return","the","mean","of","the","bootstraps","std",":","if","``","True","``","return","the","standard","deviation","of","the","bootstraps","quantile",":","if","given",",","returns","the","quantile","of","the","bootstraps",".","Can","only","be","used","with","pytorch","version","1.6","or","higher","raw",":","if","``","True","``",",","return","all","bootstrapped","values","sampling_strategy",":","Determines","how","to","produce","bootstrapped","samplings",".","Either","``","'poisson","'","``","or","``","multinomial","``",".","If","``","'possion","'","``","is","chosen",",","the","number","of","times","each","sample","will","be","included","in","the","bootstrap","will","be","given","by",":","math",":","`","n\\sim","Poisson","(","\\lambda=1",")","`",",","which","approximates","the","true","bootstrap","distribution","when","the","number","of","samples","is","large",".","If","``","'multinomial","'","``","is","chosen",",","we","will","apply","true","bootstrapping","at","the","batch","level","to","approximate","bootstrapping","over","the","hole","dataset",".","kwargs",":","Additional","keyword","arguments",",","see",":","ref",":","`","Metric","kwargs","`","for","more","info",".","Example",":",":",">",">",">","from","pprint","import","pprint",">",">",">","from","torchmetrics.wrappers","import","BootStrapper",">",">",">","from","torchmetrics.classification","import","MulticlassAccuracy",">",">",">","_","=","torch.manual_seed","(","123",")",">",">",">","base_metric","=","MulticlassAccuracy","(","num_classes=5",",","average='micro","'",")",">",">",">","bootstrap","=","BootStrapper","(","base_metric",",","num_bootstraps=20",")",">",">",">","bootstrap.update","(","torch.randint","(","5",",","(","20",",",")",")",",","torch.randint","(","5",",","(","20",",",")",")",")",">",">",">","output","=","bootstrap.compute","(",")",">",">",">","pprint","(","output",")","{","'mean","'",":","tensor","(","0.2205",")",",","'std","'",":","tensor","(","0.0859",")","}"]
docstr: Compute the bootstrapped metric values.
  
  Always returns a dict of tensors, which can contain the following keys: ``mean``, ``std``, ``quantile`` and
  ``raw`` depending on how the class was initialized.
docstr_tok: ["Compute","the","bootstrapped","metric","values",".","Always","returns","a","dict","of","tensors",",","which","can","contain","the","following","keys",":","``","mean","``",",","``","std","``",",","``","quantile","``","and","``","raw","``","depending","on","how","the","class","was","initialized","."]
code: def compute(self) -> Dict[str, Tensor]:
      """Compute the bootstrapped metric values.
  
      Always returns a dict of tensors, which can contain the following keys: ``mean``, ``std``, ``quantile`` and
      ``raw`` depending on how the class was initialized.
  
      """
      computed_vals = torch.stack(
          [m.compute() for m in self.metrics], dim=0
      )
      output_dict = {}
      if self.mean:
          output_dict["mean"] = computed_vals.mean(dim=0)
      if self.std:
          output_dict["std"] = computed_vals.std(dim=0)
      if self.quantile is not None:
          output_dict["quantile"] = torch.quantile(
              computed_vals, self.quantile
          )
      if self.raw:
          output_dict["raw"] = computed_vals
      return output_dict
  
file_path: torchmetrics/src/torchmetrics/wrappers/bootstrapping.py
imports: from copy import deepcopy
  from typing import Any, Dict, Optional, Sequence, Union
  import torch
  from lightning_utilities import apply_to_collection
  from torch import Tensor
  from torch.nn import ModuleList
  from torchmetrics.metric import Metric
  from torchmetrics.utilities.imports import _MATPLOTLIB_AVAILABLE
  from torchmetrics.utilities.plot import _AX_TYPE, _PLOT_OUT_TYPE
  from torchmetrics.wrappers.abstract import WrapperMetric
label_desc: Use image node_id 3 for calling the BootStrapper obj's underlying member method code with example usage: obj.compute() and returns: output_dict