Open ABehal2020 opened 2 years ago
Hi @ABehal2020 This seems to be a torchmetrics
version issue. Can you check what's the version of torchmetrics
in your environment? As specified in environment.yml, version 0.6.2 should work.
I followed these instructions in the bondnet branch in this rxnrep repo as I would like to use the update bondnet:
git clone https://github.com/mjwen/rxnrep.git cd rxnrep git checkout bondnet conda env create -f environment.yml conda activate rxnrep pip install -r requirements.txt pip install -e .
My torchmetrics subsequently was 0.9.3 - I downgraded by running the following: conda install torchmetrics=0.6.2
I then tried to train the model by running the following:
(rxnrep) Adityas-MacBook-Pro:rxnrep adityabehal$ python run.py model/decoder=regressor.yaml datamodule=regression/electrolyte.yaml
Traceback (most recent call last):
File "run.py", line 6, in
After installing wandb, I reran the training command: python run.py model/decoder=regressor.yaml
This gave me another stack trace:
(rxnrep) Adityas-MacBook-Pro:rxnrep adityabehal$ python run.py model/decoder=regressor.yaml datamodule=regression/electrolyte.yaml
Using backend: pytorch
⚙ CONFIG
├── seed
│ └── 35
├── restore
│ └── False
├── skip_test
│ └── False
├── git_repo_path
│ └── None
├── return_val_metric_score
│ └── False
├── original_working_dir
│ └── /Users/adityabehal/Documents/RPI/RCOS/IBM-quantum-computing/rxnrep
├── datamodule
│ └── regression:
│ target: rxnrep.data.electrolyte.ElectrolyteRegressionDataModule
│ batch_size: 100
│ num_workers: 0
│ pin_memory: true
│ state_dict_filename: dataset_state_dict.yaml
│ testset_filename: /Users/mjwen/Documents/Dataset/electrolyte/reactions_n2000_test.json
│ trainset_filename: /Users/mjwen/Documents/Dataset/electrolyte/reactions_n2000_train.json
│ valset_filename: /Users/mjwen/Documents/Dataset/electrolyte/reactions_n2000_val.json
│
├── model
│ └── decoder:
│ cfg_adjuster:
│ target: rxnrep.model.regressor.adjust_config
│ model_class:
│ target: rxnrep.model.regressor.LightningModel
│ property_name:
│ - reaction_energy
│ regression_decoder_hidden_layer_sizes:
│ - - 64
│ - 50
│ regression_decoder_num_layers:
│ - 2
│ encoder:
│ activation: ReLU
│ combine_reactants_products: difference
│ conv: GatedGCNConv
│ conv_layer_size: 64
│ embedding_size: 64
│ has_global_feats: true
│ mlp_diff_layer_batch_norm: true
│ mlp_diff_layer_sizes: []
│ mlp_pool_layer_batch_norm: true
│ mlp_pool_layer_sizes: []
│ molecule_batch_norm: true
│ molecule_conv_layer_sizes:
│ - 64
│ - 64
│ molecule_dropout: 0.0
│ molecule_num_fc_layers: 2
│ molecule_residual: true
│ num_mlp_diff_layers: 0
│ num_mlp_pool_layers: 0
│ num_mol_conv_layers: 2
│ num_rxn_conv_layers: 0
│ pool_atom_feats: true
│ pool_bond_feats: false
│ pool_global_feats: false
│ pool_kwargs: null
│ pool_method: attentive_reduce_sum
│ reaction_batch_norm: true
│ reaction_conv_layer_sizes: []
│ reaction_dropout: 0.0
│ reaction_num_fc_layers: 2
│ reaction_residual: true
│
├── optimizer
│ └── lr: 0.001
│ lr_scheduler:
│ epochs: 10
│ lr_min: 1.0e-06
│ lr_warmup_step: 10
│ scheduler_name: cosine
│ weight_decay: 1.0e-06
│
├── trainer
│ └── target: pytorch_lightning.Trainer
│ max_epochs: 10
│ num_sanity_val_steps: 2
│ progress_bar_refresh_rate: 100
│ resume_from_checkpoint: null
│ sync_batchnorm: true
│ weights_summary: top
│
├── logger
│ └── wandb:
│ target: pytorch_lightning.loggers.wandb.WandbLogger
│ id: null
│ project: tmp-rxnrep
│
└── callbacks
└── early_stopping:
target: pytorch_lightning.callbacks.EarlyStopping
min_delta: 0
mode: max
monitor: val/score
patience: 100
verbose: true
model_checkpoint:
target: pytorch_lightning.callbacks.ModelCheckpoint
mode: max
monitor: val/score
save_last: true
save_top_k: 3
verbose: false
Global seed set to 35
[2022-08-09 18:17:12,828][/Users/adityabehal/Documents/RPI/RCOS/IBM-quantum-computing/rxnrep/rxnrep/train.py][INFO] - Instantiating datamodule: rxnrep.data.electrolyte.ElectrolyteRegressionDataModule
[2022-08-09 18:17:14,898][mip.model][INFO] - Using Python-MIP package version 1.13.0
[2022-08-09 18:17:14,910][rxnrep.data.electrolyte][INFO] - Start reading dataset file...
Traceback (most recent call last):
File "run.py", line 64, in
I appreciate any help. Thank you!
I believe these 3 JSON files need to be pushed to the bondnet branch for rxnrep repo for local training to work on my computer:
trainset_filename: /Users/mjwen/Documents/Dataset/electrolyte/reactions_n2000_train.json valset_filename: /Users/mjwen/Documents/Dataset/electrolyte/reactions_n2000_val.json testset_filename: /Users/mjwen/Documents/Dataset/electrolyte/reactions_n2000_test.json
Thank you!
ah, thanks for catching this! Just added the dataset to the repo. Please pull the latest bondnet
branch to get it.
I followed these instructions in the bondnet branch in this rxnrep repo as I would like to use the update bondnet:
git clone https://github.com/mjwen/rxnrep.git cd rxnrep git checkout bondnet conda env create -f environment.yml conda activate rxnrep pip install -r requirements.txt pip install -e .
My torchmetrics subsequently was 0.9.3 - I downgraded by running the following: conda install torchmetrics=0.6.2
I then tried to train the model by running the following:
(rxnrep) Adityas-MacBook-Pro:rxnrep adityabehal$ python run.py model/decoder=regressor.yaml datamodule=regression/electrolyte.yaml Traceback (most recent call last): File "run.py", line 6, in from rxnrep.train import train File "/Users/adityabehal/Documents/RPI/RCOS/IBM-quantum-computing/rxnrep/rxnrep/train.py", line 5, in import wandb ModuleNotFoundError: No module named 'wandb' (rxnrep) Adityas-MacBook-Pro:rxnrep adityabehal$ conda install wandb
After installing wandb, I reran the training command: python run.py model/decoder=regressor.yaml
Thanks for the detailed info. torchmetrics==0.6.2
was specified as a dependence in the main
branch but not in the bondnet
branch. This has been fixed. Also, wandb
is added as a dependence.
Thanks! I updated my local rxnrep folder with the latest bondnet branch changes.
New stack trace when running model training command locally on my Mac (prediction on pretrained model works):
(rxnrep) Adityas-MacBook-Pro:rxnrep adityabehal$ python run.py model/decoder=regressor.yaml datamodule=regression/electrolyte.yaml
Using backend: pytorch
⚙ CONFIG
├── seed
│ └── 35
├── restore
│ └── False
├── skip_test
│ └── False
├── git_repo_path
│ └── None
├── return_val_metric_score
│ └── False
├── original_working_dir
│ └── /Users/adityabehal/Documents/RPI/RCOS/IBM-quantum-computing/rxnrep
├── datamodule
│ └── regression:
│ target: rxnrep.data.electrolyte.ElectrolyteRegressionDataModule
│ batch_size: 100
│ num_workers: 0
│ pin_memory: true
│ state_dict_filename: dataset_state_dict.yaml
│ testset_filename: ./dataset/reactions_n2000_test.json
│ trainset_filename: ./dataset/reactions_n2000_train.json
│ valset_filename: ./dataset/reactions_n2000_val.json
│
├── model
│ └── decoder:
│ cfg_adjuster:
│ target: rxnrep.model.regressor.adjust_config
│ model_class:
│ target: rxnrep.model.regressor.LightningModel
│ property_name:
│ - reaction_energy
│ regression_decoder_hidden_layer_sizes:
│ - - 64
│ - 50
│ regression_decoder_num_layers:
│ - 2
│ encoder:
│ activation: ReLU
│ combine_reactants_products: difference
│ conv: GatedGCNConv
│ conv_layer_size: 64
│ embedding_size: 64
│ has_global_feats: true
│ mlp_diff_layer_batch_norm: true
│ mlp_diff_layer_sizes: []
│ mlp_pool_layer_batch_norm: true
│ mlp_pool_layer_sizes: []
│ molecule_batch_norm: true
│ molecule_conv_layer_sizes:
│ - 64
│ - 64
│ molecule_dropout: 0.0
│ molecule_num_fc_layers: 2
│ molecule_residual: true
│ num_mlp_diff_layers: 0
│ num_mlp_pool_layers: 0
│ num_mol_conv_layers: 2
│ num_rxn_conv_layers: 0
│ pool_atom_feats: true
│ pool_bond_feats: false
│ pool_global_feats: false
│ pool_kwargs: null
│ pool_method: attentive_reduce_sum
│ reaction_batch_norm: true
│ reaction_conv_layer_sizes: []
│ reaction_dropout: 0.0
│ reaction_num_fc_layers: 2
│ reaction_residual: true
│
├── optimizer
│ └── lr: 0.001
│ lr_scheduler:
│ epochs: 10
│ lr_min: 1.0e-06
│ lr_warmup_step: 10
│ scheduler_name: cosine
│ weight_decay: 1.0e-06
│
├── trainer
│ └── target: pytorch_lightning.Trainer
│ max_epochs: 10
│ num_sanity_val_steps: 2
│ progress_bar_refresh_rate: 100
│ resume_from_checkpoint: null
│ sync_batchnorm: true
│ weights_summary: top
│
├── logger
│ └── wandb:
│ target: pytorch_lightning.loggers.wandb.WandbLogger
│ id: null
│ project: tmp-rxnrep
│
└── callbacks
└── early_stopping:
target: pytorch_lightning.callbacks.EarlyStopping
min_delta: 0
mode: max
monitor: val/score
patience: 100
verbose: true
model_checkpoint:
target: pytorch_lightning.callbacks.ModelCheckpoint
mode: max
monitor: val/score
save_last: true
save_top_k: 3
verbose: false
Global seed set to 35
[2022-08-09 22:46:15,494][/Users/adityabehal/Documents/RPI/RCOS/IBM-quantum-computing/rxnrep/rxnrep/train.py][INFO] - Instantiating datamodule: rxnrep.data.electrolyte.ElectrolyteRegressionDataModule
[2022-08-09 22:46:17,836][mip.model][INFO] - Using Python-MIP package version 1.13.0
[2022-08-09 22:46:17,847][rxnrep.data.electrolyte][INFO] - Start reading dataset file...
Traceback (most recent call last):
File "run.py", line 64, in
Modify electrolyte.yaml to set the trainset_filename
, valset_filename
and testset_filename
to the absolute path of the data files on your machine. The data files are located at the dataset directory of the repo.
Thanks! Local training works now. I'd like to use my locally trained model to make predictions. When I train the model and then run prediction, here's the output:
(rxnrep) Adityas-MacBook-Pro:rxnrep adityabehal$ bondnet examples/reactions_mrnet.json Using backend: pytorch
Find model directory ./rxnrep_model
; will reuse it.
Finish making predictions. Results written to result.json
. The bond dissociation energy is denoted by predicted_reaction_energy
in each reaction.
I believe it is still using the pretrained model that was pulled earlier from Google Drive. How can I make the predict command use the locally trained model?
Yes, it is using the pretrained model. Instructions to your own model added to README.
Thanks! I updated the datamodule/regression/electrolyte.yaml file local paths to point to the train, test, and validation mrnet files on my computer. I have a few questions:
Traceback (most recent call last):
File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/bin/bondnet", line 33, in
Thanks! I updated the datamodule/regression/electrolyte.yaml file local paths to point to the train, test, and validation mrnet files on my computer. I have a few questions:
- While training the model, I only get one test point that is viewable on Wandb. Does this correspond to the average of all the test dataset points to depict the average test loss after the model training is finished?
It is correct behavior to see only one test error, because test is only performed at the ending of the training using the best performing model. Also, the test error is the mean absolute error for the entire test set. So, if you want to get prediction error for each individual points, you will need to use the bondnet
predict command.
- Also, what does the trainer/global_step on the x axis correspond to? Is there a way I can see training and validation learning curves graphed on an epoch by epoch basis?
In training deep neural nets, we train in mini batches, the global step corresponds to the number of mini batch steps. Alternatively, you can also view the epochs (i.e. the number of iterations of passing your training data) by choosing it from the upper right dropdown from the wandb interface.
- While trying to generate predictions from my locally trained model, I get the following stack trace: (rxnrep) Adityas-MacBook-Pro:rxnrep adityabehal$ bondnet examples/reactions_mrnet.json --model outputs/2022-08-12/22-42-44
Have no immediate idea why this happens. Some guesses: 1. did you pip install
the repo? 2. are you issuing the bondnet
command in the repo?
Thank you for all your help!
Hi,
I really love rxnrep's bondnet implementation, and I've enjoyed working with it so far. I have a couple more questions:
(rxnrep) cary-50:rxnrep adityabehal$ bondnet /Users/adityabehal/Documents/RPI/RCOS/IBM-ML-Chemistry/rxnrep/examples/reactions_mrnet.json --model /Users/adityabehal/Documents/RPI/RCOS/IBM-ML-Chemistry/rxnrep/outputs/2022-11-04-smiles
Using backend: pytorch
Using local model /Users/adityabehal/Documents/RPI/RCOS/IBM-ML-Chemistry/rxnrep/outputs/2022-11-04-smiles
to make predictions
Traceback (most recent call last):
File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/bin/bondnet", line 33, in
It was working earlier, but after some update to the bondnet branch of this rxnrep repo, it's not working and I'm not sure if this is an issue on my end.
I got the following stack trace:
[2022-11-04 17:38:57,788][/Users/adityabehal/Documents/RPI/RCOS/IBM-ML-Chemistry/rxnrep/rxnrep/train.py][INFO] - Instantiating datamodule: rxnrep.data.nrel.NRELDataModule [2022-11-04 17:38:59,925][mip.model][INFO] - Using Python-MIP package version 1.13.0 [2022-11-04 17:39:00,048][rxnrep.data.nrel][INFO] - Start reading dataset ... [2022-11-04 17:39:01,950][rxnrep.data.nrel][INFO] - Finish reading dataset. Number succeed 9582, number failed 0. [2022-11-04 17:39:01,950][rxnrep.data.dataset][INFO] - Starting building graphs and featurizing... Traceback (most recent call last): File "/Users/adityabehal/Documents/RPI/RCOS/IBM-ML-Chemistry/rxnrep/rxnrep/data/grapher.py", line 350, in build_graph_and_featurize_reaction atom_map_number = reaction.get_reactants_atom_map_number(zero_based=True) File "/Users/adityabehal/Documents/RPI/RCOS/IBM-ML-Chemistry/rxnrep/rxnrep/core/reaction.py", line 298, in get_reactants_atom_map_number return self._get_atom_map_number(self.reactants, zero_based) File "/Users/adityabehal/Documents/RPI/RCOS/IBM-ML-Chemistry/rxnrep/rxnrep/core/reaction.py", line 595, in _get_atom_map_number minimum = int(np.min(np.concatenate(atom_map_number))) File "<__array_function__ internals>", line 180, in amin File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 2918, in amin return _wrapreduction(a, np.minimum, 'min', axis, None, out, File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction return ufunc.reduce(obj, axis, dtype, out, **passkwargs) TypeError: '<=' not supported between instances of 'NoneType' and 'NoneType'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "run.py", line 64, in
I'm wondering if rxnrep can predict individual molecular properties as is or if I'll need to modify it to do so.
I've attached a zip file of the test, train, and val solubility dataset tsv files I'm passing in solubility-data-files.zip if you're interested in taking a quick look.
Thank you for all your help so far!
The model directory --model /Users/adityabehal/Documents/RPI/RCOS/IBM-ML-Chemistry/rxnrep/outputs/2022-11-04-smiles
seems a bit suspicious to me. Can you check whether there is a wandb
directory in it? The prediction code will look for a wandb
directory, where the trained model is located.
The short answer is no. The current rxnrep and bondnet are for reaction properties, and not for molecular properties. It is possible to modify it to predict molecular properties, but since there are a lot of other great repos to do it, I am not sure whether you want to do it or not. As an example, check out dgl-lifesci for molecular properties prediction.
Out of curiosity, is the solubility data set you linked from some published paper or public database?
// using locally trained mrnet model for prediction on mrnet data (will it work with smiles data too?)
(rxnrep) cary-50:rxnrep adityabehal$ bondnet /Users/adityabehal/Documents/RPI/RCOS/IBM-ML-Chemistry/rxnrep/examples/reactions_mrnet.json --model /Users/adityabehal/Documents/RPI/RCOS/IBM-ML-Chemistry/rxnrep/outputs/2022-11-05/15-28-33
Using backend: pytorch
Using local model /Users/adityabehal/Documents/RPI/RCOS/IBM-ML-Chemistry/rxnrep/outputs/2022-11-05/15-28-33
to make predictions
Finish making predictions. Results written to result.json
. The bond dissociation energy is denoted by predicted_reaction_energy
in each reaction.
// using locally trained smiles model for prediction (fails on mrnet data - does it only work on smiles data?)
(rxnrep) cary-50:rxnrep adityabehal$ bondnet /Users/adityabehal/Documents/RPI/RCOS/IBM-ML-Chemistry/rxnrep/examples/reactions_mrnet.json --model /Users/adityabehal/Documents/RPI/RCOS/IBM-ML-Chemistry/rxnrep/outputs/2022-11-05/15-29-30
Using backend: pytorch
Using local model /Users/adityabehal/Documents/RPI/RCOS/IBM-ML-Chemistry/rxnrep/outputs/2022-11-05/15-29-30
to make predictions
Traceback (most recent call last):
File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/bin/bondnet", line 33, in
Thanks for letting me know! I'll check it out.
The solubility dataset is publicly available at https://github.com/whitead/dmol-book/raw/master/data/curated-solubility-dataset.csv - I originally saw it in the dmol tutorials (https://dmol.pub/dl/gnn.html).
Models trained using smiles can be used for mrnet and vice versa. In prediction, we need to initialize the model and then load the trained model. But the default parameters (e.g. atom feature dimension) for smiles and mrnet input are different, then you see the RuntimeError: The size of tensor a (12) must match the size of tensor b (35) at non-singleton dimension 1
error.
More specifically, take a look at this and this. They need to be updated to be the same, and then it should work.
And, thanks for the dataset source!
Thank you - I have some questions about smiles string formatting.
I noticed that your SMILES data is differently formatted than the solubility SMILES data (e.g. your SMILES data has a lot more brackets). Is there a way to go between these 2 forms or a converter? Or this just a different convention for representing smiles reactions?
Also, given a SMILES string for a reaction, how can I separate it into reactants and products? Did you just use the ">>" as the delimiter between the reactants and products side?
Is there a way to indicate the solvent for reactions or individual molecules overall?
I followed the instructions in the GitHub repo bondnet branch to use the updated version of bondnet.
When I tried to train, I get the following error:
(rxnrep) Adityas-MacBook-Pro:rxnrep adityabehal$ python run.py model/decoder=regressor.yaml datamodule=regression/electrolyte.yaml Traceback (most recent call last): File "run.py", line 6, in
from rxnrep.train import train
File "/Users/adityabehal/Documents/RPI/RCOS/IBM-quantum-computing/rxnrep/rxnrep/train.py", line 7, in
from pytorch_lightning import (
File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/lib/python3.8/site-packages/pytorch_lightning/init.py", line 20, in
from pytorch_lightning import metrics # noqa: E402
File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/lib/python3.8/site-packages/pytorch_lightning/metrics/init.py", line 15, in
from pytorch_lightning.metrics.classification import ( # noqa: F401
File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/lib/python3.8/site-packages/pytorch_lightning/metrics/classification/init.py", line 14, in
from pytorch_lightning.metrics.classification.accuracy import Accuracy # noqa: F401
File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/lib/python3.8/site-packages/pytorch_lightning/metrics/classification/accuracy.py", line 18, in
from pytorch_lightning.metrics.utils import deprecated_metrics
File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/lib/python3.8/site-packages/pytorch_lightning/metrics/utils.py", line 22, in
from torchmetrics.utilities.data import get_num_classes as _get_num_classes
ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data' (/Users/adityabehal/opt/anaconda3/envs/rxnrep/lib/python3.8/site-packages/torchmetrics/utilities/data.py)
When I try to predict, I get the following error (I assume if the model is not trained locally then it should default to the pretrained version?):
(rxnrep) Adityas-MacBook-Pro:rxnrep adityabehal$ bondnet examples/reactions_mrnet.json Traceback (most recent call last): File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/bin/bondnet", line 33, in
sys.exit(load_entry_point('rxnrep', 'console_scripts', 'bondnet')())
File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/bin/bondnet", line 25, in importlib_load_entry_point
return next(matches).load()
File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/lib/python3.8/importlib/metadata.py", line 77, in load
module = import_module(match.group('module'))
File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 848, in exec_module
File "", line 219, in _call_with_frames_removed
File "/Users/adityabehal/Documents/RPI/RCOS/IBM-quantum-computing/rxnrep/predict.py", line 15, in
from rxnrep.data.electrolyte import ElectrolyteDataset
File "/Users/adityabehal/Documents/RPI/RCOS/IBM-quantum-computing/rxnrep/rxnrep/data/electrolyte.py", line 9, in
from rxnrep.data.datamodule import (
File "/Users/adityabehal/Documents/RPI/RCOS/IBM-quantum-computing/rxnrep/rxnrep/data/datamodule.py", line 5, in
from pytorch_lightning import LightningDataModule
File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/lib/python3.8/site-packages/pytorch_lightning/init.py", line 20, in
from pytorch_lightning import metrics # noqa: E402
File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/lib/python3.8/site-packages/pytorch_lightning/metrics/init.py", line 15, in
from pytorch_lightning.metrics.classification import ( # noqa: F401
File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/lib/python3.8/site-packages/pytorch_lightning/metrics/classification/init.py", line 14, in
from pytorch_lightning.metrics.classification.accuracy import Accuracy # noqa: F401
File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/lib/python3.8/site-packages/pytorch_lightning/metrics/classification/accuracy.py", line 18, in
from pytorch_lightning.metrics.utils import deprecated_metrics
File "/Users/adityabehal/opt/anaconda3/envs/rxnrep/lib/python3.8/site-packages/pytorch_lightning/metrics/utils.py", line 22, in
from torchmetrics.utilities.data import get_num_classes as _get_num_classes
ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data' (/Users/adityabehal/opt/anaconda3/envs/rxnrep/lib/python3.8/site-packages/torchmetrics/utilities/data.py)