class_docstr: Calculate Fréchet inception distance (FID_) which is used to access the quality of generated images.
  
  .. math::
      FID = \|\mu - \mu_w\|^2 + tr(\Sigma + \Sigma_w - 2(\Sigma \Sigma_w)^{\frac{1}{2}})
  
  where :math:`\mathcal{N}(\mu, \Sigma)` is the multivariate normal distribution estimated from Inception v3
  (`fid ref1`_) features calculated on real life images and :math:`\mathcal{N}(\mu_w, \Sigma_w)` is the
  multivariate normal distribution estimated from Inception v3 features calculated on generated (fake) images.
  The metric was originally proposed in `fid ref1`_.
  
  Using the default feature extraction (Inception v3 using the original weights from `fid ref2`_), the input is
  expected to be mini-batches of 3-channel RGB images of shape ``(3xHxW)``. If argument ``normalize``
  is ``True`` images are expected to be dtype ``float`` and have values in the ``[0,1]`` range, else if
  ``normalize`` is set to ``False`` images are expected to have dtype ``uint8`` and take values in the ``[0, 255]``
  range. All images will be resized to 299 x 299 which is the size of the original training data. The boolian
  flag ``real`` determines if the images should update the statistics of the real distribution or the
  fake distribution.
  
  This metric is known to be unstable in its calculatations, and we recommend for the best results using this metric
  that you calculate using `torch.float64` (default is `torch.float32`) which can be set using the `.set_dtype`
  method of the metric.
  
  .. note:: using this metrics requires you to have torch 1.9 or higher installed
  
  .. note:: using this metric with the default feature extractor requires that ``torch-fidelity``
      is installed. Either install as ``pip install torchmetrics[image]`` or ``pip install torch-fidelity``
  
  As input to ``forward`` and ``update`` the metric accepts the following input
  
  - ``imgs`` (:class:`~torch.Tensor`): tensor with images feed to the feature extractor with
  - ``real`` (:class:`~bool`): bool indicating if ``imgs`` belong to the real or the fake distribution
  
  As output of `forward` and `compute` the metric returns the following output
  
  - ``fid`` (:class:`~torch.Tensor`): float scalar tensor with mean FID value over samples
  
  Args:
      feature:
          Either an integer or ``nn.Module``:
  
          - an integer will indicate the inceptionv3 feature layer to choose. Can be one of the following:
            64, 192, 768, 2048
          - an ``nn.Module`` for using a custom feature extractor. Expects that its forward method returns
            an ``(N,d)`` matrix where ``N`` is the batch size and ``d`` is the feature size.
  
      reset_real_features: Whether to also reset the real features. Since in many cases the real dataset does not
          change, the features can be cached them to avoid recomputing them which is costly. Set this to ``False`` if
          your dataset does not change.
      kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.
  
  .. note::
      If a custom feature extractor is provided through the `feature` argument it is expected to either have a
      attribute called ``num_features`` that indicates the number of features returned by the forward pass or
      alternatively we will pass through tensor of shape ``(1, 3, 299, 299)`` and dtype ``torch.uint8``` to the
      forward pass and expect a tensor of shape ``(1, num_features)`` as output.
  
  Raises:
      ValueError:
          If torch version is lower than 1.9
      ModuleNotFoundError:
          If ``feature`` is set to an ``int`` (default settings) and ``torch-fidelity`` is not installed
      ValueError:
          If ``feature`` is set to an ``int`` not in [64, 192, 768, 2048]
      TypeError:
          If ``feature`` is not an ``str``, ``int`` or ``torch.nn.Module``
      ValueError:
          If ``reset_real_features`` is not an ``bool``
  
  Example:
      >>> import torch
      >>> _ = torch.manual_seed(123)
      >>> from torchmetrics.image.fid import FrechetInceptionDistance
      >>> fid = FrechetInceptionDistance(feature=64)
      >>> # generate two slightly overlapping image intensity distributions
      >>> imgs_dist1 = torch.randint(0, 200, (100, 3, 299, 299), dtype=torch.uint8)
      >>> imgs_dist2 = torch.randint(100, 255, (100, 3, 299, 299), dtype=torch.uint8)
      >>> fid.update(imgs_dist1, real=True)
      >>> fid.update(imgs_dist2, real=False)
      >>> fid.compute()
      tensor(12.7202)
class_docstr_tok: ["Calculate","Fr\u00e9chet","inception","distance","(","FID_",")","which","is","used","to","access","the","quality","of","generated","images",".","..","math",":",":","FID","=","\\|\\mu","-","\\mu_w\\|^2","+","tr","(","\\Sigma","+","\\Sigma_w","-","2","(","\\Sigma","\\Sigma_w",")","^","{","\\frac","{","1","}","{","2","}","}",")","where",":","math",":","`","\\mathcal","{","N","}","(","\\mu",",","\\Sigma",")","`","is","the","multivariate","normal","distribution","estimated","from","Inception","v3","(","`","fid","ref1","`","_",")","features","calculated","on","real","life","images","and",":","math",":","`","\\mathcal","{","N","}","(","\\mu_w",",","\\Sigma_w",")","`","is","the","multivariate","normal","distribution","estimated","from","Inception","v3","features","calculated","on","generated","(","fake",")","images",".","The","metric","was","originally","proposed","in","`","fid","ref1","`","_",".","Using","the","default","feature","extraction","(","Inception","v3","using","the","original","weights","from","`","fid","ref2","`","_",")",",","the","input","is","expected","to","be","mini-batches","of","3-channel","RGB","images","of","shape","``","(","3xHxW",")","``",".","If","argument","``","normalize","``","is","``","True","``","images","are","expected","to","be","dtype","``","float","``","and","have","values","in","the","``","[","0,1","]","``","range",",","else","if","``","normalize","``","is","set","to","``","False","``","images","are","expected","to","have","dtype","``","uint8","``","and","take","values","in","the","``","[","0",",","255","]","``","range",".","All","images","will","be","resized","to","299","x","299","which","is","the","size","of","the","original","training","data",".","The","boolian","flag","``","real","``","determines","if","the","images","should","update","the","statistics","of","the","real","distribution","or","the","fake","distribution",".","This","metric","is","known","to","be","unstable","in","its","calculatations",",","and","we","recommend","for","the","best","results","using","this","metric","that","you","calculate","using","`","torch.float64","`","(","default","is","`","torch.float32","`",")","which","can","be","set","using","the","`",".set_dtype","`","method","of","the","metric",".","..","note",":",":","using","this","metrics","requires","you","to","have","torch","1.9","or","higher","installed","..","note",":",":","using","this","metric","with","the","default","feature","extractor","requires","that","``","torch-fidelity","``","is","installed",".","Either","install","as","``","pip","install","torchmetrics","[","image","]","``","or","``","pip","install","torch-fidelity","``","As","input","to","``","forward","``","and","``","update","``","the","metric","accepts","the","following","input","-","``","imgs","``","(",":","class",":","`","~torch.Tensor","`",")",":","tensor","with","images","feed","to","the","feature","extractor","with","-","``","real","``","(",":","class",":","`","~bool","`",")",":","bool","indicating","if","``","imgs","``","belong","to","the","real","or","the","fake","distribution","As","output","of","`","forward","`","and","`","compute","`","the","metric","returns","the","following","output","-","``","fid","``","(",":","class",":","`","~torch.Tensor","`",")",":","float","scalar","tensor","with","mean","FID","value","over","samples","Args",":","feature",":","Either","an","integer","or","``","nn.Module","``",":","-","an","integer","will","indicate","the","inceptionv3","feature","layer","to","choose",".","Can","be","one","of","the","following",":","64",",","192",",","768",",","2048","-","an","``","nn.Module","``","for","using","a","custom","feature","extractor",".","Expects","that","its","forward","method","returns","an","``","(","N",",","d",")","``","matrix","where","``","N","``","is","the","batch","size","and","``","d","``","is","the","feature","size",".","reset_real_features",":","Whether","to","also","reset","the","real","features",".","Since","in","many","cases","the","real","dataset","does","not","change",",","the","features","can","be","cached","them","to","avoid","recomputing","them","which","is","costly",".","Set","this","to","``","False","``","if","your","dataset","does","not","change",".","kwargs",":","Additional","keyword","arguments",",","see",":","ref",":","`","Metric","kwargs","`","for","more","info",".","..","note",":",":","If","a","custom","feature","extractor","is","provided","through","the","`","feature","`","argument","it","is","expected","to","either","have","a","attribute","called","``","num_features","``","that","indicates","the","number","of","features","returned","by","the","forward","pass","or","alternatively","we","will","pass","through","tensor","of","shape","``","(","1",",","3",",","299",",","299",")","``","and","dtype","``","torch.uint8","``","`","to","the","forward","pass","and","expect","a","tensor","of","shape","``","(","1",",","num_features",")","``","as","output",".","Raises",":","ValueError",":","If","torch","version","is","lower","than","1.9","ModuleNotFoundError",":","If","``","feature","``","is","set","to","an","``","int","``","(","default","settings",")","and","``","torch-fidelity","``","is","not","installed","ValueError",":","If","``","feature","``","is","set","to","an","``","int","``","not","in","[","64",",","192",",","768",",","2048","]","TypeError",":","If","``","feature","``","is","not","an","``","str","``",",","``","int","``","or","``","torch.nn.Module","``","ValueError",":","If","``","reset_real_features","``","is","not","an","``","bool","``","Example",":",">",">",">","import","torch",">",">",">","_","=","torch.manual_seed","(","123",")",">",">",">","from","torchmetrics.image.fid","import","FrechetInceptionDistance",">",">",">","fid","=","FrechetInceptionDistance","(","feature=64",")",">",">",">","#","generate","two","slightly","overlapping","image","intensity","distributions",">",">",">","imgs_dist1","=","torch.randint","(","0",",","200",",","(","100",",","3",",","299",",","299",")",",","dtype=torch.uint8",")",">",">",">","imgs_dist2","=","torch.randint","(","100",",","255",",","(","100",",","3",",","299",",","299",")",",","dtype=torch.uint8",")",">",">",">","fid.update","(","imgs_dist1",",","real=True",")",">",">",">","fid.update","(","imgs_dist2",",","real=False",")",">",">",">","fid.compute","(",")","tensor","(","12.7202",")"]
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.image.fid import FrechetInceptionDistance
      >>> imgs_dist1 = torch.randint(0, 200, (100, 3, 299, 299), dtype=torch.uint8)
      >>> imgs_dist2 = torch.randint(100, 255, (100, 3, 299, 299), dtype=torch.uint8)
      >>> metric = FrechetInceptionDistance(feature=64)
      >>> metric.update(imgs_dist1, real=True)
      >>> metric.update(imgs_dist2, real=False)
      >>> fig_, ax_ = metric.plot()
  
  .. plot::
      :scale: 75
  
      >>> # Example plotting multiple values
      >>> import torch
      >>> from torchmetrics.image.fid import FrechetInceptionDistance
      >>> imgs_dist1 = lambda: torch.randint(0, 200, (100, 3, 299, 299), dtype=torch.uint8)
      >>> imgs_dist2 = lambda: torch.randint(100, 255, (100, 3, 299, 299), dtype=torch.uint8)
      >>> metric = FrechetInceptionDistance(feature=64)
      >>> values = [ ]
      >>> for _ in range(3):
      ...     metric.update(imgs_dist1(), real=True)
      ...     metric.update(imgs_dist2(), real=False)
      ...     values.append(metric.compute())
      ...     metric.reset()
      >>> 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.image.fid","import","FrechetInceptionDistance",">",">",">","imgs_dist1","=","torch.randint","(","0",",","200",",","(","100",",","3",",","299",",","299",")",",","dtype=torch.uint8",")",">",">",">","imgs_dist2","=","torch.randint","(","100",",","255",",","(","100",",","3",",","299",",","299",")",",","dtype=torch.uint8",")",">",">",">","metric","=","FrechetInceptionDistance","(","feature=64",")",">",">",">","metric.update","(","imgs_dist1",",","real=True",")",">",">",">","metric.update","(","imgs_dist2",",","real=False",")",">",">",">","fig_",",","ax_","=","metric.plot","(",")","..","plot",":",":",":","scale",":","75",">",">",">","#","Example","plotting","multiple","values",">",">",">","import","torch",">",">",">","from","torchmetrics.image.fid","import","FrechetInceptionDistance",">",">",">","imgs_dist1","=","lambda",":","torch.randint","(","0",",","200",",","(","100",",","3",",","299",",","299",")",",","dtype=torch.uint8",")",">",">",">","imgs_dist2","=","lambda",":","torch.randint","(","100",",","255",",","(","100",",","3",",","299",",","299",")",",","dtype=torch.uint8",")",">",">",">","metric","=","FrechetInceptionDistance","(","feature=64",")",">",">",">","values","=","[","]",">",">",">","for","_","in","range","(","3",")",":","...","metric.update","(","imgs_dist1","(",")",",","real=True",")","...","metric.update","(","imgs_dist2","(",")",",","real=False",")","...","values.append","(","metric.compute","(",")",")","...","metric.reset","(",")",">",">",">","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.image.fid import FrechetInceptionDistance
          >>> imgs_dist1 = torch.randint(0, 200, (100, 3, 299, 299), dtype=torch.uint8)
          >>> imgs_dist2 = torch.randint(100, 255, (100, 3, 299, 299), dtype=torch.uint8)
          >>> metric = FrechetInceptionDistance(feature=64)
          >>> metric.update(imgs_dist1, real=True)
          >>> metric.update(imgs_dist2, real=False)
          >>> fig_, ax_ = metric.plot()
  
      .. plot::
          :scale: 75
  
          >>> # Example plotting multiple values
          >>> import torch
          >>> from torchmetrics.image.fid import FrechetInceptionDistance
          >>> imgs_dist1 = lambda: torch.randint(0, 200, (100, 3, 299, 299), dtype=torch.uint8)
          >>> imgs_dist2 = lambda: torch.randint(100, 255, (100, 3, 299, 299), dtype=torch.uint8)
          >>> metric = FrechetInceptionDistance(feature=64)
          >>> values = [ ]
          >>> for _ in range(3):
          ...     metric.update(imgs_dist1(), real=True)
          ...     metric.update(imgs_dist2(), real=False)
          ...     values.append(metric.compute())
          ...     metric.reset()
          >>> fig_, ax_ = metric.plot(values)
  
      """
      return self._plot(val, ax)
  
imports: from copy import deepcopy
  from typing import Any, List, Optional, Sequence, Tuple, Union
  import torch
  from torch import Tensor
  from torch.nn import Module
  from torch.nn.functional import adaptive_avg_pool2d
  from torchmetrics.metric import Metric
  from torchmetrics.utilities.imports import _MATPLOTLIB_AVAILABLE, _TORCH_FIDELITY_AVAILABLE
  from torchmetrics.utilities.plot import _AX_TYPE, _PLOT_OUT_TYPE
label_desc: Use image node_id 6 for calling the FrechetInceptionDistance obj's underlying member method code with example usage: obj.plot(val, ax) and returns: self