o
    .wi                     @   s  d dl mZ d dlmZmZmZmZmZ d dlm	Z	 d dl
mZmZmZmZmZmZ d dlZd dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZmZmZ d dlm Z  d dl!m"Z"m#Z#m$Z$ e slddgZ%de&de&de&fddZ'de&de&de&fddZ(G dd deZ)dS )    )OrderedDict)HashableIterableIteratorMappingSequence)deepcopy)AnyClassVarDictListOptionalUnionN)Tensor)
ModuleDict)Literal)Metric)rank_zero_warn)_flatten_flatten_dictallclose)_MATPLOTLIB_AVAILABLE)_AX_TYPE_PLOT_OUT_TYPEplot_single_or_multi_valMetricCollection.plotzMetricCollection.plot_allstringprefixreturnc                 C   s   |  |r| t|d S | S )zPatch for older version with missing method `removeprefix`.

    >>> _remove_prefix("prefix_string", "prefix_")
    'string'
    >>> _remove_prefix("not_prefix_string", "prefix_")
    'not_prefix_string'

    N)
startswithlen)r   r    r!   U/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/torchmetrics/collections.py_remove_prefix#   s   	r#   suffixc                 C   s    |  |r| dt|  S | S )zPatch for older version with missing method `removesuffix`.

    >>> _remove_suffix("string_suffix", "_suffix")
    'string'
    >>> _remove_suffix("string_suffix_missing", "_suffix")
    'string_suffix_missing'

    N)endswithr    )r   r$   r!   r!   r"   _remove_suffix/   s    	r&   c                       s^  e Zd ZU dZeeef ed< dgZe	e
e  ed< dddddeed eeed f  eeeed f f f d	ed
ee dee deee
e
e  f ddf fddZedeeeeef f fddZejjdededeeef fddZdededdfddZdUddZedededefddZdVdeddfd d!Zdeeef fd"d#Zd$ed% dededeeef fd&d'ZdUd(d)ZdWd
ee dee dd fd*d+Z dXd,eddfd-d.Z!deed eeed f  eeeed f f f d	eddfd/d0Z"dUd1d2Z#ede$e%e&e f fd3d4Z'd5edefd6d7Z(de)eef fd8d9Z*de+e, fd:d;Z-dVd<ede.e, fd=d>Z/dYd<ed?ede.e0eef  fd@dAZ1dXd?ede.e fdBdCZ2dXdDed?edefdEdFZ3edGee dHedee fdIdJZ4def fdKdLZ5dMeeej6f dd fdNdOZ7			dZdPeeeee f  dQeee8ee8 f  dRedee9 fdSdTZ:  Z;S )[MetricCollectiona&  MetricCollection class can be used to chain metrics that have the same call pattern into one single class.

    Args:
        metrics: One of the following

            * list or tuple (sequence): if metrics are passed in as a list or tuple, will use the metrics class name
              as key for output dict. Therefore, two metrics of the same class cannot be chained this way.

            * arguments: similar to passing in as a list, metrics passed in as arguments will use their metric
              class name as key for the output dict.

            * dict: if metrics are passed in as a dict, will use each key in the dict as key for output dict.
              Use this format if you want to chain together multiple of the same metric with different parameters.
              Note that the keys in the output dict will be sorted alphabetically.

        prefix: a string to append in front of the keys of the output dict

        postfix: a string to append after the keys of the output dict

        compute_groups:
            By default the MetricCollection will try to reduce the computations needed for the metrics in the collection
            by checking if they belong to the same **compute group**. All metrics in a compute group share the same
            metric state and are therefore only different in their compute step e.g. accuracy, precision and recall
            can all be computed from the true positives/negatives and false positives/negatives. By default,
            this argument is ``True`` which enables this feature. Set this argument to `False` for disabling
            this behaviour. Can also be set to a list of lists of metrics for setting the compute groups yourself.

    .. tip::
        The compute groups feature can significantly speedup the calculation of metrics under the right conditions.
        First, the feature is only available when calling the ``update`` method and not when calling ``forward`` method
        due to the internal logic of ``forward`` preventing this. Secondly, since we compute groups share metric
        states by reference, calling ``.items()``, ``.values()`` etc. on the metric collection will break this
        reference and a copy of states are instead returned in this case (reference will be reestablished on the next
        call to ``update``). Do note that for the time being that if you are manually specifying compute groups in
        nested collections, these are not compatible with the compute groups of the parent collection and will be
        overridden.

    .. important::
        Metric collections can be nested at initialization (see last example) but the output of the collection will
        still be a single flatten dictionary combining the prefix and postfix arguments from the nested collection.

    Raises:
        ValueError:
            If one of the elements of ``metrics`` is not an instance of ``pl.metrics.Metric``.
        ValueError:
            If two elements in ``metrics`` have the same ``name``.
        ValueError:
            If ``metrics`` is not a ``list``, ``tuple`` or a ``dict``.
        ValueError:
            If ``metrics`` is ``dict`` and additional_metrics are passed in.
        ValueError:
            If ``prefix`` is set and it is not a string.
        ValueError:
            If ``postfix`` is set and it is not a string.

    Example::
        In the most basic case, the metrics can be passed in as a list or tuple. The keys of the output dict will be
        the same as the class name of the metric:

        >>> from torch import tensor
        >>> from pprint import pprint
        >>> from torchmetrics import MetricCollection
        >>> from torchmetrics.regression import MeanSquaredError
        >>> from torchmetrics.classification import MulticlassAccuracy, MulticlassPrecision, MulticlassRecall
        >>> target = tensor([0, 2, 0, 2, 0, 1, 0, 2])
        >>> preds = tensor([2, 1, 2, 0, 1, 2, 2, 2])
        >>> metrics = MetricCollection([MulticlassAccuracy(num_classes=3, average='micro'),
        ...                             MulticlassPrecision(num_classes=3, average='macro'),
        ...                             MulticlassRecall(num_classes=3, average='macro')])
        >>> metrics(preds, target)  # doctest: +NORMALIZE_WHITESPACE
        {'MulticlassAccuracy': tensor(0.1250),
         'MulticlassPrecision': tensor(0.0667),
         'MulticlassRecall': tensor(0.1111)}

    Example::
        Alternatively, metrics can be passed in as arguments. The keys of the output dict will be the same as the
        class name of the metric:

        >>> metrics = MetricCollection(MulticlassAccuracy(num_classes=3, average='micro'),
        ...                            MulticlassPrecision(num_classes=3, average='macro'),
        ...                            MulticlassRecall(num_classes=3, average='macro'))
        >>> metrics(preds, target)  # doctest: +NORMALIZE_WHITESPACE
        {'MulticlassAccuracy': tensor(0.1250),
         'MulticlassPrecision': tensor(0.0667),
         'MulticlassRecall': tensor(0.1111)}

    Example::
        If multiple of the same metric class (with different parameters) should be chained together, metrics can be
        passed in as a dict and the output dict will have the same keys as the input dict:

        >>> metrics = MetricCollection({'micro_recall': MulticlassRecall(num_classes=3, average='micro'),
        ...                             'macro_recall': MulticlassRecall(num_classes=3, average='macro')})
        >>> same_metric = metrics.clone()
        >>> pprint(metrics(preds, target))
        {'macro_recall': tensor(0.1111), 'micro_recall': tensor(0.1250)}
        >>> pprint(same_metric(preds, target))
        {'macro_recall': tensor(0.1111), 'micro_recall': tensor(0.1250)}

    Example::
        Metric collections can also be nested up to a single time. The output of the collection will still be a single
        dict with the prefix and postfix arguments from the nested collection:

        >>> metrics = MetricCollection([
        ...     MetricCollection([
        ...         MulticlassAccuracy(num_classes=3, average='macro'),
        ...         MulticlassPrecision(num_classes=3, average='macro')
        ...     ], postfix='_macro'),
        ...     MetricCollection([
        ...         MulticlassAccuracy(num_classes=3, average='micro'),
        ...         MulticlassPrecision(num_classes=3, average='micro')
        ...     ], postfix='_micro'),
        ... ], prefix='valmetrics/')
        >>> pprint(metrics(preds, target))  # doctest: +NORMALIZE_WHITESPACE
        {'valmetrics/MulticlassAccuracy_macro': tensor(0.1111),
         'valmetrics/MulticlassAccuracy_micro': tensor(0.1250),
         'valmetrics/MulticlassPrecision_macro': tensor(0.0667),
         'valmetrics/MulticlassPrecision_micro': tensor(0.1250)}

    Example::
        The `compute_groups` argument allow you to specify which metrics should share metric state. By default, this
        will automatically be derived but can also be set manually.

        >>> metrics = MetricCollection(
        ...     MulticlassRecall(num_classes=3, average='macro'),
        ...     MulticlassPrecision(num_classes=3, average='macro'),
        ...     MeanSquaredError(),
        ...     compute_groups=[['MulticlassRecall', 'MulticlassPrecision'], ['MeanSquaredError']]
        ... )
        >>> metrics.update(preds, target)
        >>> pprint(metrics.compute())
        {'MeanSquaredError': tensor(2.3750), 'MulticlassPrecision': tensor(0.0667), 'MulticlassRecall': tensor(0.1111)}
        >>> pprint(metrics.compute_groups)
        {0: ['MulticlassRecall', 'MulticlassPrecision'], 1: ['MeanSquaredError']}

    _modulesmetric_state__jit_unused_properties__NT)r   postfixcompute_groupsmetricsadditional_metricsr   r+   r,   r   c                   sT   t    | |d| _| |d| _|| _d| _d| _i | _| j	|g|R   d S )Nr   r+   F)
super__init__
_check_argr   r+   _enable_compute_groups_groups_checked_state_is_copy_groupsadd_metrics)selfr-   r   r+   r,   r.   	__class__r!   r"   r0      s   
zMetricCollection.__init__c                 C   s   dd | j dddD S )z$Get the current state of the metric.c                 S   s   i | ]\}}||j qS r!   )r)   ).0kmr!   r!   r"   
<dictcomp>   s    z1MetricCollection.metric_state.<locals>.<dictcomp>F	keep_base
copy_state)itemsr7   r!   r!   r"   r)      s   zMetricCollection.metric_stateargskwargsc                 O   s   | j dg|R i |S )zCall forward for each metric sequentially.

        Positional arguments (args) will be passed to every metric in the collection, while keyword arguments (kwargs)
        will be filtered based on the signature of the individual metric.

        forward_compute_and_reduce)r7   rC   rD   r!   r!   r"   rE      s   zMetricCollection.forwardc           	      O   s   | j r<| jddD ]}t| t|}d|_q	| j D ]}t| |d }|j|i |jdi | qd| _	| 
  dS | jddD ]}|jdi |}|j|i | qB| jrh|   d| _	| 
  d| _ dS dS )zCall update for each metric sequentially.

        Positional arguments (args) will be passed to every metric in the collection, while keyword arguments (kwargs)
        will be filtered based on the signature of the individual metric.

        Tr?   Nr   Fr@   r!   )r3   keysgetattrstr	_computedr5   valuesupdate_filter_kwargsr4    _compute_groups_create_state_refr2   _merge_compute_groups)	r7   rC   rD   r;   micgm0r<   m_kwargsr!   r!   r"   rO      s$   
zMetricCollection.updatec                 C   s   t | j}	 t| j D ]@\}}t| j D ]+\}}||kr!qt| |d }t| |d }| ||rC| j| | j|  nqt | j|krM nqt | j|krVnt | j}qt| j}i | _t|	 D ]	\}	}
|
| j|	< qjdS )aA  Iterate over the collection of metrics, checking if the state of each metric matches another.

        If so, their compute groups will be merged into one. The complexity of the method is approximately
        ``O(number_of_metrics_in_collection ** 2)``, as all metrics need to be compared to all other metrics.

        Tr   N)
r    r5   r   rA   rK   _equal_metric_statesextendpop	enumeraterN   )r7   
num_groupscg_idx1cg_members1cg_idx2cg_members2metric1metric2tempidxrN   r!   r!   r"   rR     s0   


z&MetricCollection._merge_compute_groupsr`   ra   c                 C   s   t | jdkst |jdkrdS | j |j krdS | jD ]H}t| |}t||}t|t|kr6 dS t|trNt|trN|j|jkrKt||sN dS t|t	rgt|t	rgt
dd t||D sg dS qdS )z6Check if the metric state of two metrics are the same.r   Fc                 s   s*    | ]\}}|j |j kot||V  qd S N)shaper   )r:   s1s2r!   r!   r"   	<genexpr>L  s   ( z8MetricCollection._equal_metric_states.<locals>.<genexpr>T)r    	_defaultsrJ   rK   type
isinstancer   re   r   listallzip)r`   ra   keystate1state2r!   r!   r"   rW   1  s0   


z%MetricCollection._equal_metric_statesFcopyc                 C   s   | j sE| j D ]<}t| |d }tdt|D ]+}t| || }|jD ]}t||}t|||r4t|n| q$|r?t|j	n|j	|_	qq|| _ dS )zCreate reference between metrics in the same compute group.

        Args:
            copy: If `True` the metric state will between members will be copied instead
                of just passed by reference

        r      N)
r4   r5   rN   rK   ranger    ri   setattrr   _update_count)r7   rr   rT   rU   irS   statem0_stater!   r!   r"   rQ   R  s   


z1MetricCollection._compute_groups_create_state_refc                 C   s
   |  dS )z5Compute the result for each metric in the collection.computerF   rB   r!   r!   r"   rz   f  s   
zMetricCollection.computemethod_name)rz   rE   c                    s^  i } j dddD ]*\}}|dkr| }n|dkr(||i |jdi |}ntd| |||< q	t|\}}	i }
 j dddD ]`\}}|| }t|tr|  D ]I\}}|	ru|t|ddd}|t|d	dd}| d
| }t|ddr|j	dur|j	 | }t|ddr|j
dur| |j
 }||
|< qTqC||
|< qC fdd|
  D S )a  Compute result from collection and reduce into a single dictionary.

        Args:
            method_name: The method to call on each metric in the collection.
                Should be either `compute` or `forward`.
            args: Positional arguments to pass to each metric (if method_name is `forward`)
            kwargs: Keyword arguments to pass to each metric (if method_name is `forward`)

        Raises:
            ValueError:
                If method_name is not `compute` or `forward`.

        TFr>   rz   rE   z=method_name should be either 'compute' or 'forward', but got r    r+   __from_collectionNc                    s   i | ]
\}}  ||qS r!   )	_set_name)r:   r;   vrB   r!   r"   r=         z8MetricCollection._compute_and_reduce.<locals>.<dictcomp>r!   )rA   rz   rP   
ValueErrorr   rk   dictreplacerK   r   r+   )r7   r{   rC   rD   resultr;   r<   resr}   
duplicatesflattened_resultsro   r   
stripped_kr!   rB   r"   rG   j  s4   




z$MetricCollection._compute_and_reducec                 C   s:   | j ddD ]}|  q| jr| jr|   dS dS dS )z(Call reset for each metric sequentially.FrI   N)rN   resetr2   r3   rQ   )r7   r<   r!   r!   r"   r     s
   
zMetricCollection.resetc                 C   s0   t | }|r| |d|_|r| |d|_|S )zMake a copy of the metric collection.

        Args:
            prefix: a string to append in front of the metric keys
            postfix: a string to append after the keys of the output dict.

        r   r+   )r   r1   r   r+   )r7   r   r+   mcr!   r!   r"   clone  s   zMetricCollection.clonemodec                 C   s    | j ddD ]}|| qdS )zOChange if metric states should be saved to its state_dict after initialization.FrI   N)rN   
persistent)r7   r   r<   r!   r!   r"   r     s   zMetricCollection.persistentc           
      G   s&  t |tr|g}t |tr1t|}g }|D ]}t |tr|n|}|| q|r0td| d n|r>td| d| dt |trt|	 D ]A}|| }t |tt
fsatd| d| dt |trk|| |< qI|jdd	D ]\}}	|j|	_|j|	_d
|	_|	| | d| < qqqInut |tr|D ]D}t |tt
fstd| dt |tr|jj}|| v rtd| || |< q|jdd	D ]\}}	|j|	_|j|	_d
|	_|	| |< qqn(t |t
r|jdd	D ]\}}|| v rtd| d|| |< qntd| d| _| jr|   dS i | _dS )z%Add new metrics to Metric Collection.z You have passes extra arguments z0 which are not `Metric` so they will be ignored.z7 which are not compatible with first passed dictionary z so they will be ignored.zValue z belonging to key zO is not an instance of `torchmetrics.Metric` or `torchmetrics.MetricCollection`FrH   Tr}   Input zd to `MetricCollection` is not a instance of `torchmetrics.Metric` or `torchmetrics.MetricCollection`z#Encountered two metrics both named zMetric with name 'z#' already exists in the collection.zxUnknown input to MetricCollection. Expected, `Metric`, `MetricCollection` or `dict`/`sequence` of the previous, but got N)rk   r   r   rl   appendr   r   r   sortedrJ   r'   rA   r+   r   r~   r9   __name__r3   r2   _init_compute_groupsr5   )
r7   r-   r.   remainr<   selnamemetricr;   r   r!   r!   r"   r6     s   













zMetricCollection.add_metricsc                 C   s   t | jtrYtt| j| _| j D ]}|D ]}|| vr/td| d| j d| jdd qqt	| j }t
| j}| jddD ]}||vrS|g| j|< |d7 }qCd| _d	S dd t| jddD | _d	S )
zInitialize compute groups.

        If user provided a list, we check that all metrics in the list are also in the collection. If set to `True` we
        simply initialize each metric in the collection as its own group

        r   z_ in `compute_groups` argument does not match a metric in the collection. Please make sure that z	 matches TrH   rs   c                 S   s   i | ]
\}}|t |gqS r!   )rL   )r:   rw   r;   r!   r!   r"   r=   "  r   z9MetricCollection._init_compute_groups.<locals>.<dictcomp>N)rk   r2   rl   r   rZ   r5   rN   r   rJ   r   r    r3   )r7   r   r   already_in_groupcounterr;   r!   r!   r"   r   	  s.   


 z%MetricCollection._init_compute_groupsc                 C   s   | j S )z@Return a dict with the current compute groups in the collection.)r5   rB   r!   r!   r"   r,   $  s   zMetricCollection.compute_groupsbasec                 C   s0   | j du r|n| j | }| jdu r|S || j S )z3Adjust name of metric with both prefix and postfix.N)r   r+   )r7   r   r   r!   r!   r"   r   )  s   zMetricCollection._set_namec                 C   s<   t | jtr	t ni }| j D ]\}}||| |< q|S rd   )rk   r(   r   rA   r   )r7   dict_modulesr;   r   r!   r!   r"   _to_renamed_dict.  s   z!MetricCollection._to_renamed_dictc                 C   s   t |  S )z3Return an iterator over the keys of the MetricDict.)iterrJ   rB   r!   r!   r"   __iter__5  s   zMetricCollection.__iter__r?   c                 C   s   |r| j  S |   S )zReturn an iterable of the ModuleDict key.

        Args:
            keep_base: Whether to add prefix/postfix on the items collection.

        )r(   rJ   r   )r7   r?   r!   r!   r"   rJ   :  s   
zMetricCollection.keysr@   c                 C   s$   |  | |r| j S |   S )a&  Return an iterable of the ModuleDict key/value pairs.

        Args:
            keep_base: Whether to add prefix/postfix on the collection.
            copy_state:
                If metric states should be copied between metrics in the same compute group or just passed by reference

        )rQ   r(   rA   r   )r7   r?   r@   r!   r!   r"   rA   E  s   
	
zMetricCollection.itemsc                 C   s   |  | | j S )zReturn an iterable of the ModuleDict values.

        Args:
            copy_state:
                If metric states should be copied between metrics in the same compute group or just passed by reference

        )rQ   r(   rN   )r7   r@   r!   r!   r"   rN   S  s   

zMetricCollection.valuesro   c                 C   s8   |  | | jrt|| j}| jrt|| j}| j| S )a  Retrieve a single metric from the collection.

        Args:
            key: name of metric to retrieve
            copy_state:
                If metric states should be copied between metrics in the same compute group or just passed by reference

        )rQ   r   r#   r+   r&   r(   )r7   ro   r@   r!   r!   r"   __getitem__^  s   
	
zMetricCollection.__getitem__argr   c                 C   s.   | d u s	t | tr| S td| dt|  )NzExpected input `z` to be a string, but got )rk   rL   r   rj   )r   r   r!   r!   r"   r1   n  s   zMetricCollection._check_argc                    sb   t   dd }| jr|d| j | jrdnd 7 }| jr-|| js$dnd d| j 7 }|d S )z[Return the representation of the metric collection including all metrics in the collection.Nz,
  prefix=,r|   z
  postfix=z
))r/   __repr__r   r+   )r7   repr_strr8   r!   r"   r   t  s   zMetricCollection.__repr__dst_typec                 C   s    | j ddD ]}|| q| S )zTransfer all metric state to specific dtype. Special version of standard `type` method.

        Arguments:
            dst_type: the desired type as ``torch.dtype`` or string.

        FrI   )rN   	set_dtype)r7   r   r<   r!   r!   r"   r   }  s   zMetricCollection.set_dtypevalaxtogetherc           	         sR  t |tstdt| |durJ|r#t |ts#tdt| d|sJt |tr;tdd |D r;t|t| ksJtdt| dt| d	|pO|  }|rXt	||d
S g }t
| jdddD ]C\}\ }t |tr|j|  |dur{|| n|d
\}}nt |tr|j fdd|D |dur|| n|d
\}}|||f qc|S )a
  Plot a single or multiple values from the metric.

        The plot method has two modes of operation. If argument `together` is set to `False` (default), the `.plot`
        method of each metric will be called individually and the result will be list of figures. If `together` is set
        to `True`, the values of all metrics will instead be plotted in the same figure.

        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: Either a single instance of matplotlib axis object or an sequence of matplotlib axis objects. If
                provided, will add the plots to the provided axis objects. If not provided, will create a new. If
                argument `together` is set to `True`, a single object is expected. If `together` is set to `False`,
                the number of axis objects needs to be the same length as the number of metrics in the collection.
            together: If `True`, will plot all metrics in the same axis. If `False`, will plot each metric in a separate

        Returns:
            Either install tuple of Figure and Axes object or an sequence of tuples with Figure and Axes object for each
            metric in the collection.

        Raises:
            ModuleNotFoundError:
                If `matplotlib` is not installed
            ValueError:
                If `together` is not an bool
            ValueError:
                If `ax` is not an instance of matplotlib axis object or a sequence of matplotlib axis objects

        .. plot::
            :scale: 75

            >>> # Example plotting a single value
            >>> import torch
            >>> from torchmetrics import MetricCollection
            >>> from torchmetrics.classification import BinaryAccuracy, BinaryPrecision, BinaryRecall
            >>> metrics = MetricCollection([BinaryAccuracy(), BinaryPrecision(), BinaryRecall()])
            >>> metrics.update(torch.rand(10), torch.randint(2, (10,)))
            >>> fig_ax_ = metrics.plot()

        .. plot::
            :scale: 75

            >>> # Example plotting multiple values
            >>> import torch
            >>> from torchmetrics import MetricCollection
            >>> from torchmetrics.classification import BinaryAccuracy, BinaryPrecision, BinaryRecall
            >>> metrics = MetricCollection([BinaryAccuracy(), BinaryPrecision(), BinaryRecall()])
            >>> values = []
            >>> for _ in range(10):
            ...     values.append(metrics(torch.rand(10), torch.randint(2, (10,))))
            >>> fig_, ax_ = metrics.plot(values, together=True)

        z6Expected argument `together` to be a boolean, but got Nz?Expected argument `ax` to be a matplotlib axis object, but got z when `together=True`c                 s   s    | ]}t |tV  qd S rd   )rk   r   )r:   ar!   r!   r"   rh     s    z(MetricCollection.plot.<locals>.<genexpr>zExpected argument `ax` to be a sequence of matplotlib axis objects with the same length as the number of metrics in the collection, but got z
 with len z when `together=False`)r   Fr>   c                    s   g | ]}|  qS r!   r!   )r:   r   r;   r!   r"   
<listcomp>  s    z)MetricCollection.plot.<locals>.<listcomp>)rk   boolr   rj   r   r   rm   r    rz   r   rZ   rA   r   plotr   )	r7   r   r   r   fig_axsrw   r<   fr   r!   r   r"   r     s>   
:
(
0r   )r   N)F)NN)T)FT)NNF)<r   
__module____qualname____doc__r   rL   r   __annotations__r*   r
   rl   r   r   r   r   r0   propertyr	   r)   torchjitunusedrE   rO   rR   staticmethodrW   rQ   rz   r   rG   r   r   r   r6   r   r   intr   r,   r   r   r   r   r   r   r   rJ   tuplerA   rN   r   r1   r   dtyper   r   r   r   __classcell__r!   r!   r8   r"   r'   ;   s   
  		
  	
 $ 


/ 	

T$ 	r'   )*collectionsr   collections.abcr   r   r   r   r   rr   r   typingr	   r
   r   r   r   r   r   r   torch.nnr   typing_extensionsr   torchmetrics.metricr   torchmetrics.utilitiesr   torchmetrics.utilities.datar   r   r   torchmetrics.utilities.importsr   torchmetrics.utilities.plotr   r   r   __doctest_skip__rL   r#   r&   r'   r!   r!   r!   r"   <module>   s$    