Repository: Lightning-AI/torchmetrics

Issue:
Let IDE(s) know public symbols
## 🚀 Feature (or Bug?)
I'm using Pylance on VSCode, and it doesn't autocomplete, for example, `Accuracy` even if I typed the following:

```python
from torchmetrics import Ac
```

This is because imported symbols are considered private by default (by at least pylance (pyright) as documented [here](https://github.com/microsoft/pyright/blob/main/docs/typed-libraries.md#library-interface)).

### Motivation
For better coding experience (autocomplete + docstring reference) :]

### Pitch
As stated in https://github.com/microsoft/pyright/blob/main/docs/typed-libraries.md#library-interface, we have the following options to explicitly make symbols public.

#### 1. Add `__all__` to `__init__.py` files.
```python
# torchmetrics/__init__.py
from torchmetrics.classification import (
    Accuracy,
    ...
)
__all__ = [
    "Accuracy",
    ...
]
```

#### 2. Use wildcard imports.
```python
# torchmetrics/__init__.py
from torchmetrics.classification import *

# torchmetrics/classification/__init__.py
__all__ = [
    "Accuracy",
    ...
]
```

#### 3. Use redundant symbol aliases.
```python
# torchmetrics/__init__.py
from torchmetrics.classification import (
    Accuracy as Accuracy,
    ...
)
```

### Additional context
https://github.com/microsoft/pylance-release/issues/1032
https://github.com/microsoft/pyright/pull/1877


Discussion:
Hi! thanks for your contribution!, great first issue!
@akihironitta sounds good to me :]
I would prefer option 1 but have no strong opinions here.

Resolving patch:
diff --git a/torchmetrics/__init__.py b/torchmetrics/__init__.py
--- a/torchmetrics/__init__.py
+++ b/torchmetrics/__init__.py
@@ -11,9 +11,10 @@
 _PACKAGE_ROOT = os.path.dirname(__file__)
 _PROJECT_ROOT = os.path.dirname(_PACKAGE_ROOT)
 
-from torchmetrics.audio import PIT, SI_SDR, SI_SNR, SNR  # noqa: E402, F401
-from torchmetrics.average import AverageMeter  # noqa: E402, F401
-from torchmetrics.classification import (  # noqa: E402, F401
+from torchmetrics import functional  # noqa: E402
+from torchmetrics.audio import PIT, SI_SDR, SI_SNR, SNR  # noqa: E402
+from torchmetrics.average import AverageMeter  # noqa: E402
+from torchmetrics.classification import (  # noqa: E402
     AUC,
     AUROC,
     F1,
@@ -38,10 +39,10 @@
     Specificity,
     StatScores,
 )
-from torchmetrics.collections import MetricCollection  # noqa: E402, F401
-from torchmetrics.image import FID, IS, KID, PSNR, SSIM  # noqa: E402, F401
-from torchmetrics.metric import Metric  # noqa: E402, F401
-from torchmetrics.regression import (  # noqa: E402, F401
+from torchmetrics.collections import MetricCollection  # noqa: E402
+from torchmetrics.image import FID, IS, KID, PSNR, SSIM  # noqa: E402
+from torchmetrics.metric import Metric  # noqa: E402
+from torchmetrics.regression import (  # noqa: E402
     CosineSimilarity,
     ExplainedVariance,
     MeanAbsoluteError,
@@ -53,7 +54,7 @@
     SpearmanCorrcoef,
     SymmetricMeanAbsolutePercentageError,
 )
-from torchmetrics.retrieval import (  # noqa: E402, F401
+from torchmetrics.retrieval import (  # noqa: E402
     RetrievalFallOut,
     RetrievalMAP,
     RetrievalMRR,
@@ -61,5 +62,64 @@
     RetrievalPrecision,
     RetrievalRecall,
 )
-from torchmetrics.text import WER, BLEUScore, ROUGEScore  # noqa: E402, F401
-from torchmetrics.wrappers import BootStrapper  # noqa: E402, F401
+from torchmetrics.text import WER, BLEUScore, ROUGEScore  # noqa: E402
+from torchmetrics.wrappers import BootStrapper  # noqa: E402
+
+__all__ = [
+    "functional",
+    "Accuracy",
+    "AUC",
+    "AUROC",
+    "AverageMeter",
+    "AveragePrecision",
+    "BinnedAveragePrecision",
+    "BinnedPrecisionRecallCurve",
+    "BinnedRecallAtFixedPrecision",
+    "BLEUScore",
+    "BootStrapper",
+    "CalibrationError",
+    "CohenKappa",
+    "ConfusionMatrix",
+    "CosineSimilarity",
+    "ExplainedVariance",
+    "F1",
+    "FBeta",
+    "FID",
+    "HammingDistance",
+    "Hinge",
+    "IoU",
+    "IS",
+    "KID",
+    "KLDivergence",
+    "MatthewsCorrcoef",
+    "MeanAbsoluteError",
+    "MeanAbsolutePercentageError",
+    "MeanSquaredError",
+    "MeanSquaredLogError",
+    "Metric",
+    "MetricCollection",
+    "PearsonCorrcoef",
+    "PIT",
+    "Precision",
+    "PrecisionRecallCurve",
+    "PSNR",
+    "R2Score",
+    "Recall",
+    "RetrievalFallOut",
+    "RetrievalMAP",
+    "RetrievalMRR",
+    "RetrievalNormalizedDCG",
+    "RetrievalPrecision",
+    "RetrievalRecall",
+    "ROC",
+    "ROUGEScore",
+    "SI_SDR",
+    "SI_SNR",
+    "SNR",
+    "SpearmanCorrcoef",
+    "Specificity",
+    "SSIM",
+    "StatScores",
+    "SymmetricMeanAbsolutePercentageError",
+    "WER",
+]
diff --git a/torchmetrics/functional/__init__.py b/torchmetrics/functional/__init__.py
--- a/torchmetrics/functional/__init__.py
+++ b/torchmetrics/functional/__init__.py
@@ -11,54 +11,107 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-from torchmetrics.functional.audio.pit import pit, pit_permutate  # noqa: F401
-from torchmetrics.functional.audio.si_sdr import si_sdr  # noqa: F401
-from torchmetrics.functional.audio.si_snr import si_snr  # noqa: F401
-from torchmetrics.functional.audio.snr import snr  # noqa: F401
-from torchmetrics.functional.classification.accuracy import accuracy  # noqa: F401
-from torchmetrics.functional.classification.auc import auc  # noqa: F401
-from torchmetrics.functional.classification.auroc import auroc  # noqa: F401
-from torchmetrics.functional.classification.average_precision import average_precision  # noqa: F401
-from torchmetrics.functional.classification.calibration_error import calibration_error  # noqa: F401
-from torchmetrics.functional.classification.cohen_kappa import cohen_kappa  # noqa: F401
-from torchmetrics.functional.classification.confusion_matrix import confusion_matrix  # noqa: F401
-from torchmetrics.functional.classification.dice import dice_score  # noqa: F401
-from torchmetrics.functional.classification.f_beta import f1, fbeta  # noqa: F401
-from torchmetrics.functional.classification.hamming_distance import hamming_distance  # noqa: F401
-from torchmetrics.functional.classification.hinge import hinge  # noqa: F401
-from torchmetrics.functional.classification.iou import iou  # noqa: F401
-from torchmetrics.functional.classification.kl_divergence import kl_divergence, kldivergence  # noqa: F401
-from torchmetrics.functional.classification.matthews_corrcoef import matthews_corrcoef  # noqa: F401
-from torchmetrics.functional.classification.precision_recall import precision, precision_recall, recall  # noqa: F401
-from torchmetrics.functional.classification.precision_recall_curve import precision_recall_curve  # noqa: F401
-from torchmetrics.functional.classification.roc import roc  # noqa: F401
-from torchmetrics.functional.classification.specificity import specificity  # noqa: F401
-from torchmetrics.functional.classification.stat_scores import stat_scores  # noqa: F401
-from torchmetrics.functional.image.gradients import image_gradients  # noqa: F401
-from torchmetrics.functional.image.psnr import psnr  # noqa: F401
-from torchmetrics.functional.image.ssim import ssim  # noqa: F401
-from torchmetrics.functional.regression.cosine_similarity import cosine_similarity  # noqa: F401
-from torchmetrics.functional.regression.explained_variance import explained_variance  # noqa: F401
-from torchmetrics.functional.regression.mean_absolute_error import mean_absolute_error  # noqa: F401
-from torchmetrics.functional.regression.mean_absolute_percentage_error import (  # noqa: F401
-    mean_absolute_percentage_error,
-)
-from torchmetrics.functional.regression.mean_squared_error import mean_squared_error  # noqa: F401
-from torchmetrics.functional.regression.mean_squared_log_error import mean_squared_log_error  # noqa: F401
-from torchmetrics.functional.regression.pearson import pearson_corrcoef  # noqa: F401
-from torchmetrics.functional.regression.r2 import r2_score  # noqa: F401
-from torchmetrics.functional.regression.r2score import r2score  # noqa: F401
-from torchmetrics.functional.regression.spearman import spearman_corrcoef  # noqa: F401
-from torchmetrics.functional.regression.symmetric_mean_absolute_percentage_error import (  # noqa: F401
+from torchmetrics.functional.audio.pit import pit, pit_permutate
+from torchmetrics.functional.audio.si_sdr import si_sdr
+from torchmetrics.functional.audio.si_snr import si_snr
+from torchmetrics.functional.audio.snr import snr
+from torchmetrics.functional.classification.accuracy import accuracy
+from torchmetrics.functional.classification.auc import auc
+from torchmetrics.functional.classification.auroc import auroc
+from torchmetrics.functional.classification.average_precision import average_precision
+from torchmetrics.functional.classification.calibration_error import calibration_error
+from torchmetrics.functional.classification.cohen_kappa import cohen_kappa
+from torchmetrics.functional.classification.confusion_matrix import confusion_matrix
+from torchmetrics.functional.classification.dice import dice_score
+from torchmetrics.functional.classification.f_beta import f1, fbeta
+from torchmetrics.functional.classification.hamming_distance import hamming_distance
+from torchmetrics.functional.classification.hinge import hinge
+from torchmetrics.functional.classification.iou import iou
+from torchmetrics.functional.classification.kl_divergence import kl_divergence, kldivergence
+from torchmetrics.functional.classification.matthews_corrcoef import matthews_corrcoef
+from torchmetrics.functional.classification.precision_recall import precision, precision_recall, recall
+from torchmetrics.functional.classification.precision_recall_curve import precision_recall_curve
+from torchmetrics.functional.classification.roc import roc
+from torchmetrics.functional.classification.specificity import specificity
+from torchmetrics.functional.classification.stat_scores import stat_scores
+from torchmetrics.functional.image.gradients import image_gradients
+from torchmetrics.functional.image.psnr import psnr
+from torchmetrics.functional.image.ssim import ssim
+from torchmetrics.functional.regression.cosine_similarity import cosine_similarity
+from torchmetrics.functional.regression.explained_variance import explained_variance
+from torchmetrics.functional.regression.mean_absolute_error import mean_absolute_error
+from torchmetrics.functional.regression.mean_absolute_percentage_error import mean_absolute_percentage_error
+from torchmetrics.functional.regression.mean_squared_error import mean_squared_error
+from torchmetrics.functional.regression.mean_squared_log_error import mean_squared_log_error
+from torchmetrics.functional.regression.pearson import pearson_corrcoef
+from torchmetrics.functional.regression.r2 import r2_score
+from torchmetrics.functional.regression.r2score import r2score
+from torchmetrics.functional.regression.spearman import spearman_corrcoef
+from torchmetrics.functional.regression.symmetric_mean_absolute_percentage_error import (
     symmetric_mean_absolute_percentage_error,
 )
-from torchmetrics.functional.retrieval.average_precision import retrieval_average_precision  # noqa: F401
-from torchmetrics.functional.retrieval.fall_out import retrieval_fall_out  # noqa: F401
-from torchmetrics.functional.retrieval.ndcg import retrieval_normalized_dcg  # noqa: F401
-from torchmetrics.functional.retrieval.precision import retrieval_precision  # noqa: F401
-from torchmetrics.functional.retrieval.recall import retrieval_recall  # noqa: F401
-from torchmetrics.functional.retrieval.reciprocal_rank import retrieval_reciprocal_rank  # noqa: F401
-from torchmetrics.functional.self_supervised import embedding_similarity  # noqa: F401
-from torchmetrics.functional.text.bleu import bleu_score  # noqa: F401
-from torchmetrics.functional.text.rouge import rouge_score  # noqa: F401
-from torchmetrics.functional.text.wer import wer  # noqa: F401
+from torchmetrics.functional.retrieval.average_precision import retrieval_average_precision
+from torchmetrics.functional.retrieval.fall_out import retrieval_fall_out
+from torchmetrics.functional.retrieval.ndcg import retrieval_normalized_dcg
+from torchmetrics.functional.retrieval.precision import retrieval_precision
+from torchmetrics.functional.retrieval.recall import retrieval_recall
+from torchmetrics.functional.retrieval.reciprocal_rank import retrieval_reciprocal_rank
+from torchmetrics.functional.self_supervised import embedding_similarity
+from torchmetrics.functional.text.bleu import bleu_score
+from torchmetrics.functional.text.rouge import rouge_score
+from torchmetrics.functional.text.wer import wer
+
+__all__ = [
+    "accuracy",
+    "auc",
+    "auroc",
+    "average_precision",
+    "bleu_score",
+    "calibration_error",
+    "cohen_kappa",
+    "confusion_matrix",
+    "cosine_similarity",
+    "dice_score",
+    "embedding_similarity",
+    "explained_variance",
+    "f1",
+    "fbeta",
+    "hamming_distance",
+    "hinge",
+    "image_gradients",
+    "iou",
+    "kl_divergence",
+    "kldivergence",
+    "matthews_corrcoef",
+    "mean_absolute_error",
+    "mean_absolute_percentage_error",
+    "mean_squared_error",
+    "mean_squared_log_error",
+    "pearson_corrcoef",
+    "pit",
+    "pit_permutate",
+    "precision",
+    "precision_recall",
+    "precision_recall_curve",
+    "psnr",
+    "r2_score",
+    "r2score",
+    "recall",
+    "retrieval_average_precision",
+    "retrieval_fall_out",
+    "retrieval_normalized_dcg",
+    "retrieval_precision",
+    "retrieval_recall",
+    "retrieval_reciprocal_rank",
+    "roc",
+    "rouge_score",
+    "si_sdr",
+    "si_snr",
+    "snr",
+    "spearman_corrcoef",
+    "specificity",
+    "ssim",
+    "stat_scores",
+    "symmetric_mean_absolute_percentage_error",
+    "wer",
+]


Test patch: