Repository: Lightning-AI/pytorch-lightning
File: pytorch_lightning/metrics/classification/auroc.py (Python)

Code before:
             where each class is weighted by their support (accounts for class imbalance)
           - ``None`` computes and returns the metric per class
       max_fpr:
           If not ``None``, calculates standardized partial AUC over the
           range [0, max_fpr]. Should be a float between 0 and 1.
       compute_on_step:
           Forward only calls ``update()`` and return None if this is set to False. default: True
       dist_sync_on_step:
           Synchronize metric state across processes at each ``forward()``
           before returning the value at the step.
       process_group:
           Specify the process group on which synchronization is called. default: None (which selects the entire world)
       dist_sync_fn:
           Callback that performs the allgather operation on the metric state. When ``None``, DDP
           will be used to perform the allgather

    Raises:
        ValueError:
            If ``average`` is none of ``None``, ``"macro"`` or ``"weighted"``.
        ValueError:
            If max_fpr is not a ``float`` in the range ``0`` < max_fpr <= ``1``.
        RuntimeError:
            If ``PyTorch version`` is ``below 1.6`` since max_fpr requires `torch.bucketize`
            which is not available below 1.6.
        ValueError:
            If the mode of data (binary, multi-label, multi-class) changes between batches

    Example (binary case):

        >>> from pytorch_lightning.metrics import AUROC
        >>> preds = torch.tensor([0.13, 0.26, 0.08, 0.19, 0.34])
        >>> target = torch.tensor([0, 0, 1, 1, 1])
        >>> auroc = AUROC(pos_label=1)
        >>> auroc(preds, target)
        tensor(0.5000)

    Example (multiclass case):

        >>> from pytorch_lightning.metrics import AUROC
        >>> preds = torch.tensor([[0.90, 0.05, 0.05],
        ...                       [0.05, 0.90, 0.05],
        ...                       [0.05, 0.05, 0.90],
        ...                       [0.85, 0.05, 0.10],
        ...                       [0.10, 0.10, 0.80]])
        >>> target = torch.tensor([0, 1, 1, 2, 2])
        >>> auroc = AUROC(num_classes=3)
        >>> auroc(preds, target)
        tensor(0.7778)

    """


Review comment (performance):
```suggestion
            If the mode of data (binary, multi-label, multi-class) changes between batches.
```

Code after:
             where each class is weighted by their support (accounts for class imbalance)
           - ``None`` computes and returns the metric per class
       max_fpr:
           If not ``None``, calculates standardized partial AUC over the
           range [0, max_fpr]. Should be a float between 0 and 1.
       compute_on_step:
           Forward only calls ``update()`` and return None if this is set to False. default: True
       dist_sync_on_step:
           Synchronize metric state across processes at each ``forward()``
           before returning the value at the step.
       process_group:
           Specify the process group on which synchronization is called. default: None (which selects the entire world)
       dist_sync_fn:
           Callback that performs the allgather operation on the metric state. When ``None``, DDP
           will be used to perform the allgather

    Raises:
        ValueError:
            If ``average`` is none of ``None``, ``"macro"`` or ``"weighted"``.
        ValueError:
            If ``max_fpr`` is not a ``float`` in the range ``(0, 1]``.
        RuntimeError:
            If ``PyTorch version`` is ``below 1.6`` since max_fpr requires ``torch.bucketize``
            which is not available below 1.6.
        ValueError:
            If the mode of data (binary, multi-label, multi-class) changes between batches.

    Example (binary case):

        >>> from pytorch_lightning.metrics import AUROC
        >>> preds = torch.tensor([0.13, 0.26, 0.08, 0.19, 0.34])
        >>> target = torch.tensor([0, 0, 1, 1, 1])
        >>> auroc = AUROC(pos_label=1)
        >>> auroc(preds, target)
        tensor(0.5000)

    Example (multiclass case):

        >>> from pytorch_lightning.metrics import AUROC
        >>> preds = torch.tensor([[0.90, 0.05, 0.05],
        ...                       [0.05, 0.90, 0.05],
        ...                       [0.05, 0.05, 0.90],
        ...                       [0.85, 0.05, 0.10],
        ...                       [0.10, 0.10, 0.80]])
        >>> target = torch.tensor([0, 1, 1, 2, 2])
        >>> auroc = AUROC(num_classes=3)
        >>> auroc(preds, target)
        tensor(0.7778)

    """