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: Plot a single or multiple values from the metric.
  
  Args:
      val: Either a single result from calling `metric.forward` or `metric.compute` or a list of these results.
          If no value is provided, will automatically call `metric.compute` and plot that result.
      ax: An matplotlib axis object. If provided will add plot to that axis
  
  Returns:
      Figure and Axes object
  
  Raises:
      ModuleNotFoundError:
          If `matplotlib` is not installed
  
  .. plot::
      :scale: 75
  
      >>> # Example plotting a single value
      >>> import torch
      >>> from torchmetrics.wrappers import BootStrapper
      >>> from torchmetrics.regression import MeanSquaredError
      >>> metric = BootStrapper(MeanSquaredError(), num_bootstraps=20)
      >>> metric.update(torch.randn(100,), torch.randn(100,))
      >>> fig_, ax_ = metric.plot()
  
  .. plot::
      :scale: 75
  
      >>> # Example plotting multiple values
      >>> import torch
      >>> from torchmetrics.wrappers import BootStrapper
      >>> from torchmetrics.regression import MeanSquaredError
      >>> metric = BootStrapper(MeanSquaredError(), num_bootstraps=20)
      >>> values = [ ]
      >>> for _ in range(3):
      ...     values.append(metric(torch.randn(100,), torch.randn(100,)))
      >>> fig_, ax_ = metric.plot(values)
docstr_tok: ["Plot","a","single","or","multiple","values","from","the","metric",".","Args",":","val",":","Either","a","single","result","from","calling","`","metric.forward","`","or","`","metric.compute","`","or","a","list","of","these","results",".","If","no","value","is","provided",",","will","automatically","call","`","metric.compute","`","and","plot","that","result",".","ax",":","An","matplotlib","axis","object",".","If","provided","will","add","plot","to","that","axis","Returns",":","Figure","and","Axes","object","Raises",":","ModuleNotFoundError",":","If","`","matplotlib","`","is","not","installed","..","plot",":",":",":","scale",":","75",">",">",">","#","Example","plotting","a","single","value",">",">",">","import","torch",">",">",">","from","torchmetrics.wrappers","import","BootStrapper",">",">",">","from","torchmetrics.regression","import","MeanSquaredError",">",">",">","metric","=","BootStrapper","(","MeanSquaredError","(",")",",","num_bootstraps=20",")",">",">",">","metric.update","(","torch.randn","(","100",",",")",",","torch.randn","(","100",",",")",")",">",">",">","fig_",",","ax_","=","metric.plot","(",")","..","plot",":",":",":","scale",":","75",">",">",">","#","Example","plotting","multiple","values",">",">",">","import","torch",">",">",">","from","torchmetrics.wrappers","import","BootStrapper",">",">",">","from","torchmetrics.regression","import","MeanSquaredError",">",">",">","metric","=","BootStrapper","(","MeanSquaredError","(",")",",","num_bootstraps=20",")",">",">",">","values","=","[","]",">",">",">","for","_","in","range","(","3",")",":","...","values.append","(","metric","(","torch.randn","(","100",",",")",",","torch.randn","(","100",",",")",")",")",">",">",">","fig_",",","ax_","=","metric.plot","(","values",")"]
code: def plot(
      self,
      val: Optional[Union[Tensor, Sequence[Tensor]]] = None,
      ax: Optional[_AX_TYPE] = None,
  ) -> _PLOT_OUT_TYPE:
      """Plot a single or multiple values from the metric.
  
      Args:
          val: Either a single result from calling `metric.forward` or `metric.compute` or a list of these results.
              If no value is provided, will automatically call `metric.compute` and plot that result.
          ax: An matplotlib axis object. If provided will add plot to that axis
  
      Returns:
          Figure and Axes object
  
      Raises:
          ModuleNotFoundError:
              If `matplotlib` is not installed
  
      .. plot::
          :scale: 75
  
          >>> # Example plotting a single value
          >>> import torch
          >>> from torchmetrics.wrappers import BootStrapper
          >>> from torchmetrics.regression import MeanSquaredError
          >>> metric = BootStrapper(MeanSquaredError(), num_bootstraps=20)
          >>> metric.update(torch.randn(100,), torch.randn(100,))
          >>> fig_, ax_ = metric.plot()
  
      .. plot::
          :scale: 75
  
          >>> # Example plotting multiple values
          >>> import torch
          >>> from torchmetrics.wrappers import BootStrapper
          >>> from torchmetrics.regression import MeanSquaredError
          >>> metric = BootStrapper(MeanSquaredError(), num_bootstraps=20)
          >>> values = [ ]
          >>> for _ in range(3):
          ...     values.append(metric(torch.randn(100,), torch.randn(100,)))
          >>> fig_, ax_ = metric.plot(values)
  
      """
      return self._plot(val, ax)
  
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 5 for calling the BootStrapper obj's underlying member method code with example usage: obj.plot(val, ax) and returns: self