internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: mlcommons/GaNDLF

Issue:
Model saving is calling on `git` which causes an issue when the `subprocess` library is from the system
**Describe the bug**
When the `subprocess` library is called from the system installation of python, `git` invocation does not work, since there is no git repo for the system python installation. 

**To Reproduce**
Steps to reproduce the behavior:
1. Start GaNDLF training
2. See the following error:
```bash
$ > cat ${error_log}
[SNIP!]
  File "/geode2/home/u070/patis/BigRed200/projects/gandlf_mine/GANDLF/compute/training_loop.py", line 290, in training_loop
    save_model(
  File "/geode2/home/u070/patis/BigRed200/projects/gandlf_mine/GANDLF/utils/modelio.py", line 159, in save_model
    subprocess.check_output(["git", "rev-parse", "HEAD"])
  File "/N/soft/sles15/deeplearning/Python-3.10.10/Lib/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/N/soft/sles15/deeplearning/Python-3.10.10/Lib/subprocess.py", line 503, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/N/soft/sles15/deeplearning/Python-3.10.10/Lib/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/N/soft/sles15/deeplearning/Python-3.10.10/Lib/subprocess.py", line 1847, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
```

**Expected behavior**
The model saving should work.

**Screenshots**
N.A.

**GaNDLF Version**
<!-- Put the output of the following command:
python -c 'import GANDLF as g;print(g.__version__)'
-->
0.0.17-dev

**Desktop (please complete the following information):**
N.A.

**Additional context**
This is seen for the IU BigRed cluster. 


Discussion:

Resolving patch:
diff --git a/GANDLF/utils/modelio.py b/GANDLF/utils/modelio.py
--- a/GANDLF/utils/modelio.py
+++ b/GANDLF/utils/modelio.py
@@ -155,13 +155,14 @@ def save_model(
     model_dict["parameters"] = params
 
     try:
+        # this will try to encode the git hash of the current GaNDLF codebase, and reverts to "None" if not found
         model_dict["git_hash"] = (
-            subprocess.check_output(["git", "rev-parse", "HEAD"])
+            subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=os.getcwd())
             .decode("ascii")
             .strip()
         )
-    except subprocess.CalledProcessError:
-        model_dict["git_hash"] = None
+    except (subprocess.CalledProcessError, FileNotFoundError):
+        model_dict["git_hash"] = "None"
 
     torch.save(model_dict, path)
 


Test patch:
Repository: mlcommons/GaNDLF

Issue:
Make `black` version static
**Is your feature request related to a problem? Please describe.**
Different versions of black behave differently WRT linting, which creates issues, such as PRs having linting changes where they are not needed.

**Describe the solution you'd like**
Fix the version of `black`.

**Describe alternatives you've considered**
N.A.

**Additional context**
N.A.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -76,7 +76,7 @@ def run(self):
 
 requirements = [
     "torch==1.13.1",
-    "black",
+    "black==23.11.0",
     "numpy==1.25.0",
     "scipy",
     "SimpleITK!=2.0.*",


Test patch:
Repository: mlcommons/GaNDLF

Issue:
Porting to PyTorch 2.0
**Is your feature request related to a problem? Please describe.**
As PyTorch 2.0 is approaching its release and promising significant benefits, particularly in model compilation, it would be beneficial for GaNDLF to migrate to the platform once it becomes stable. To learn more about PyTorch 2.0, visit [here](https://pytorch.org/get-started/pytorch-2.0/).

**Describe the solution you'd like**
A transition after *tagging* GaNDLF to move to pytorch 2.0

**Describe alternatives you've considered**
N.A.

**Additional context**
N.A.


Discussion:
This is on my radar, and would also help with #562. 

My suggestion would be that once 2.0 is released, 1.13.1 will move to maintenance status, which will give us specific links for installation (right now it is the generic `pip install torch`, and putting this in our build scripts will ensure compatibility issues when new versions get released). Once we make that change, we will perform checks and tag the current codebase, and then start the migration to 2.0. 
Stale issue message
Stale issue message
Stale issue message
@szmazurek can you confirm that you are indeed working on this?
Yeah, taking care of that -  this upgrade and the related ones will be out in the next weeks.


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -81,7 +81,7 @@ def run(self):
 
 
 requirements = [
-    "torch==1.13.1",
+    "torch==2.1.0",
     "black==23.11.0",
     "numpy==1.25.0",
     "scipy",


Test patch:
Repository: mlcommons/GaNDLF

Issue:
`gdown` does not seem to be working
**Describe the bug**
Current CI seems to be broken.

**To Reproduce**
Steps to reproduce the behavior:
1. Run any CI test
2. See error:
```python-traceback
[SNIP!]
        if gdrive_file_id and is_gdrive_download_link:
            content_disposition = six.moves.urllib_parse.unquote(
                res.headers["Content-Disposition"]
            )
            m = re.search(r"filename\*=UTF-8''(.*)", content_disposition)
>           filename_from_url = m.groups()[0]
E           AttributeError: 'NoneType' object has no attribute 'groups'
```
Example: https://github.com/mlcommons/GaNDLF/actions/runs/7489779631/job/20387346791?pr=764#step:9:219

**Expected behavior**
The sample data file download should work.

**Screenshots**
N.A.

**GaNDLF Version**
Current master

**Desktop (please complete the following information):**
N.A.

**Additional context**
Basically, it is this error: https://github.com/wkentaro/gdown/issues/291



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -98,7 +98,7 @@ def run(self):
     "pyyaml",
     "tiffslide",
     "matplotlib",
-    "gdown",
+    "gdown==4.6.3",
     "pytest",
     "coverage",
     "pytest-cov",


Test patch:
diff --git a/testing/test_full.py b/testing/test_full.py
--- a/testing/test_full.py
+++ b/testing/test_full.py
@@ -123,7 +123,7 @@ def test_generic_download_data():
         if not os.path.isfile(file):
             print("Downloading and extracting sample data")
             output = os.path.join(testingDir, "gandlf_unit_test_data.tgz")
-            gdown.download(urlToDownload, output, quiet=False)
+            gdown.download(urlToDownload, output, quiet=False, verify = True)
             with zipfile.ZipFile(output, "r") as zip_ref:
                 zip_ref.extractall(testingDir)
             os.remove(output)
Repository: mlcommons/GaNDLF

Issue:
Add some SOTA optimizers
**Is your feature request related to a problem? Please describe.**
The current optimizer list in GaNDLF is [[ref](https://github.com/mlcommons/GaNDLF/blob/master/GANDLF/optimizers/__init__.py#L15)]:
- sgd
- asgd
- adam
- adamw
- adamax
- sparseadam
- rprop
- adadelta
- adagrad
- rmsprop
- radam

Though fairly extensive, it lacks some of the newer optimizers developed in the last 2-3 years.

**Describe the solution you'd like**
Add optimizers from [here](https://github.com/jettify/pytorch-optimizer). Since it is based on the `optim` module, integrating them should be straightforward, along with exposing their parameters. Also, these:
- [novograd](https://docs.monai.io/en/latest/optimizers.html#novograd)
- [warmupcosineschedule](https://docs.monai.io/en/latest/optimizers.html#warmupcosineschedule)

**Describe alternatives you've considered**
N.A.

**Additional context**
See how to add optimizer in https://github.com/mlcommons/GaNDLF/tree/master/GANDLF/optimizers 



Discussion:
Stale issue message
i can take this on

Thanks, @Ainesh06102004! This is now assigned to you.

Resolving patch:
diff --git a/GANDLF/optimizers/__init__.py b/GANDLF/optimizers/__init__.py
--- a/GANDLF/optimizers/__init__.py
+++ b/GANDLF/optimizers/__init__.py
@@ -12,6 +12,8 @@
     radam,
 )
 
+from .wrap_monai import novograd_wrapper
+
 global_optimizer_dict = {
     "sgd": sgd,
     "asgd": asgd,
@@ -24,6 +26,7 @@
     "adagrad": adagrad,
     "rmsprop": rmsprop,
     "radam": radam,
+    "novograd": novograd_wrapper
 }
 
 
diff --git a/GANDLF/optimizers/wrap_monai.py b/GANDLF/optimizers/wrap_monai.py
new file mode 100644
--- /dev/null
+++ b/GANDLF/optimizers/wrap_monai.py
@@ -0,0 +1,13 @@
+from monai.optimizers import (
+    Novograd
+)
+
+def novograd_wrapper(parameters):
+    return Novograd(
+        parameters["model_parameters"],
+        lr=parameters.get("learning_rate"),
+        betas=parameters["optimizer"].get("betas", (0.9, 0.999)),
+        eps=parameters["optimizer"].get("eps", 1e-8),
+        weight_decay=parameters["optimizer"].get("weight_decay", 3e-05),
+        amsgrad=parameters["optimizer"].get("amsgrad", False),
+    )
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -117,6 +117,7 @@ def run(self):
     "twine",
     "zarr",
     "keyring",
+    "monai==1.3.0",
 ]
 
 if __name__ == "__main__":


Test patch:
Repository: mlcommons/GaNDLF

Issue:
Upgrade PyTorch requirement from `2.1.0` to `2.1.2`
**Is your feature request related to a problem? Please describe.**
The new `2.1` versions have significant bugfixes [[ref](https://github.com/pytorch/pytorch/releases/tag/v2.1.1),[ref](https://github.com/pytorch/pytorch/releases/tag/v2.1.2)], and it would be good to enable these.

**Describe the solution you'd like**
Update `setup.py`

**Describe alternatives you've considered**
N.A.

**Additional context**
N.A.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -81,7 +81,7 @@ def run(self):
 
 
 requirements = [
-    "torch==2.1.0",
+    "torch==2.1.2",
     "black==23.11.0",
     "numpy==1.25.0",
     "scipy",
@@ -89,7 +89,7 @@ def run(self):
     "SimpleITK!=2.2.1",  # https://github.com/mlcommons/GaNDLF/issues/536
     "torchvision",
     "tqdm",
-    "torchio==0.19.3",
+    "torchio==0.19.5",
     "pandas>=2.0.0",
     "scikit-learn>=0.23.2",
     "scikit-image>=0.19.1",


Test patch:
Repository: mlcommons/GaNDLF

Issue:
Add an option for backwards compatibility for `parseConfig`
**Is your feature request related to a problem? Please describe.**
Once #783 was resolved, `parseConfig` was renamed, but this causes issues with backward compatibility (https://github.com/securefederatedai/openfl/pull/920).

**Describe the solution you'd like**
Add a new submodule to ensure backwards compatibility.

**Describe alternatives you've considered**
N.A.

**Additional context**
The PR for OpenFL still needs to be merged.



Discussion:
Happy to take this on.

Resolving patch:
diff --git a/GANDLF/parseConfig.py b/GANDLF/parseConfig.py
new file mode 100644
--- /dev/null
+++ b/GANDLF/parseConfig.py
@@ -0,0 +1,18 @@
+from .config_manager import ConfigManager
+
+
+def parseConfig(config_file_path, version_check_flag=True) -> None:
+    """
+    This function parses the configuration file and returns a dictionary of parameters.
+
+    Args:
+        config_file_path (Union[str, dict]): The filename of the configuration file.
+        version_check_flag (bool, optional): Whether to check the version in configuration file. Defaults to True.
+
+    Returns:
+        dict: The parameter dictionary.
+    """
+    print(
+        "WARNING: `GANDLF.parseConfig` will be deprecated in favor of `GANDLF.config_manager` in a future version."
+    )
+    return ConfigManager(config_file_path, version_check_flag)


Test patch:
diff --git a/testing/test_full.py b/testing/test_full.py
--- a/testing/test_full.py
+++ b/testing/test_full.py
@@ -20,6 +20,7 @@
     convert_to_tiff,
 )
 from GANDLF.config_manager import ConfigManager
+from GANDLF.parseConfig import parseConfig
 from GANDLF.training_manager import TrainingManager
 from GANDLF.inference_manager import InferenceManager
 from GANDLF.cli import (
@@ -237,7 +238,7 @@ def write_temp_config_path(parameters_to_write):
 def test_train_segmentation_rad_2d(device):
     print("03: Starting 2D Rad segmentation tests")
     # read and parse csv
-    parameters = ConfigManager(
+    parameters = parseConfig(
         testingDir + "/config_segmentation.yaml", version_check_flag=False
     )
     training_data, parameters["headers"] = parseTrainingCSV(
Repository: mlcommons/GaNDLF

Issue:
Add a script to generate information useful for debugging
**Is your feature request related to a problem? Please describe.**
Currently, we need to ask users about their environment during a debugging process, which is fairly tedious.

**Describe the solution you'd like**
Instead of asking a user to generate a standard set of information about their environment, it would be nice if this can be incorporated as a separate script which can be extended as needed.

**Describe alternatives you've considered**
N.A.

**Additional context**
N.A.


Discussion:

Resolving patch:
diff --git a/GANDLF/utils/__init__.py b/GANDLF/utils/__init__.py
--- a/GANDLF/utils/__init__.py
+++ b/GANDLF/utils/__init__.py
@@ -54,6 +54,7 @@
     print_and_format_metrics,
     determine_classification_task_type,
     getBase2,
+    get_git_hash,
 )
 
 from .modelio import (
diff --git a/GANDLF/utils/generic.py b/GANDLF/utils/generic.py
--- a/GANDLF/utils/generic.py
+++ b/GANDLF/utils/generic.py
@@ -1,4 +1,4 @@
-import os, datetime, sys
+import os, datetime, subprocess, sys
 from copy import deepcopy
 import random
 import numpy as np
@@ -329,3 +329,21 @@ def determine_classification_task_type(params: dict) -> str:
     """
     task = "binary" if params["model"]["num_classes"] == 2 else "multiclass"
     return task
+
+
+def get_git_hash() -> str:
+    """
+    Get the git hash of the current commit.
+
+    Returns:
+        str: The git hash of the current commit.
+    """
+    try:
+        git_hash = (
+            subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=os.getcwd())
+            .decode("ascii")
+            .strip()
+        )
+    except (subprocess.CalledProcessError, FileNotFoundError):
+        git_hash = "None"
+    return git_hash
diff --git a/GANDLF/utils/modelio.py b/GANDLF/utils/modelio.py
--- a/GANDLF/utils/modelio.py
+++ b/GANDLF/utils/modelio.py
@@ -1,12 +1,10 @@
-import hashlib
-import os
-import subprocess
+import hashlib, os
 from typing import Any, Dict, Optional, Tuple
 
 import torch
 
 from ..version import __version__
-from .generic import get_unique_timestamp
+from .generic import get_unique_timestamp, get_git_hash
 
 # these are the base keys for the model dictionary to save
 model_dict_full = {
@@ -155,16 +153,7 @@ def save_model(
     ).hexdigest()
     model_dict["version"] = __version__
     model_dict["parameters"] = params
-
-    try:
-        # this will try to encode the git hash of the current GaNDLF codebase, and reverts to "None" if not found
-        model_dict["git_hash"] = (
-            subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=os.getcwd())
-            .decode("ascii")
-            .strip()
-        )
-    except (subprocess.CalledProcessError, FileNotFoundError):
-        model_dict["git_hash"] = "None"
+    model_dict["git_hash"] = get_git_hash()
 
     torch.save(model_dict, path)
 


Test patch:
Repository: mlcommons/GaNDLF

Issue:
Fix some code style issues reported by codacy 
**Is your feature request related to a problem? Please describe.**
Codacy has reported a few issues to fix that relate to the code style: https://app.codacy.com/gh/mlcommons/GaNDLF/issues/current?levels=Warning&categories=CodeStyle

**Describe the solution you'd like**
Fixing this should improve readability.

**Describe alternatives you've considered**
N.A.

**Additional context**
N.A.


Discussion:
Hi @sarthakpati can you please assign this issue to me.

Resolving patch:
diff --git a/GANDLF/cli/main_run.py b/GANDLF/cli/main_run.py
--- a/GANDLF/cli/main_run.py
+++ b/GANDLF/cli/main_run.py
@@ -1,4 +1,3 @@
-import os, pickle
 from typing import Optional
 from pathlib import Path
 
@@ -9,7 +8,6 @@
     populate_header_in_parameters,
     parseTrainingCSV,
     parseTestingCSV,
-    set_determinism,
 )
 
 
diff --git a/GANDLF/losses/regression.py b/GANDLF/losses/regression.py
--- a/GANDLF/losses/regression.py
+++ b/GANDLF/losses/regression.py
@@ -1,7 +1,7 @@
 from typing import Optional
 import torch
 import torch.nn.functional as F
-from torch.nn import MSELoss, CrossEntropyLoss, L1Loss
+from torch.nn import CrossEntropyLoss
 from GANDLF.utils import one_hot
 
 


Test patch:
diff --git a/testing/test_full.py b/testing/test_full.py
--- a/testing/test_full.py
+++ b/testing/test_full.py
@@ -481,7 +481,7 @@ def test_train_regression_brainage_rad_2d(device):
     parameters["model"]["architecture"] = "brain_age"
     parameters["model"]["onnx_export"] = False
     parameters["model"]["print_summary"] = False
-    parameters_temp = copy.deepcopy(parameters)
+    # parameters_temp = copy.deepcopy(parameters)
     parameters = populate_header_in_parameters(parameters, parameters["headers"])
     sanitize_outputDir()
     TrainingManager(
@@ -753,7 +753,7 @@ def test_train_inference_optimize_classification_rad_3d(device):
     parameters["model"]["architecture"] = all_models_regression[0]
     parameters["model"]["onnx_export"] = False
     parameters["model"]["print_summary"] = False
-    parameters_temp = copy.deepcopy(parameters)
+    # parameters_temp = copy.deepcopy(parameters)
     sanitize_outputDir()
     TrainingManager(
         dataframe=training_data,
Repository: mlcommons/GaNDLF

Issue:
`gdown` does not seem to be working
**Describe the bug**
Current CI seems to be broken.

**To Reproduce**
Steps to reproduce the behavior:
1. Run any CI test
2. See error:
```python-traceback
[SNIP!]
        if gdrive_file_id and is_gdrive_download_link:
            content_disposition = six.moves.urllib_parse.unquote(
                res.headers["Content-Disposition"]
            )
            m = re.search(r"filename\*=UTF-8''(.*)", content_disposition)
>           filename_from_url = m.groups()[0]
E           AttributeError: 'NoneType' object has no attribute 'groups'
```
Example: https://github.com/mlcommons/GaNDLF/actions/runs/7489779631/job/20387346791?pr=764#step:9:219

**Expected behavior**
The sample data file download should work.

**Screenshots**
N.A.

**GaNDLF Version**
Current master

**Desktop (please complete the following information):**
N.A.

**Additional context**
Basically, it is this error: https://github.com/wkentaro/gdown/issues/291



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -98,7 +98,7 @@ def run(self):
     "pyyaml",
     "tiffslide",
     "matplotlib",
-    "gdown==4.6.3",
+    "gdown==5.1.0",
     "pytest",
     "coverage",
     "pytest-cov",


Test patch:
Repository: mlcommons/GaNDLF

Issue:
[FEATURE] Upgrade PyTorch to 2.2.1
### Is your feature request related to a problem? Please describe.
PyTorch 2.2 has been released since 30th Jan, and it would be good to update the dependency to reflect this. Full release notes are [here](https://github.com/pytorch/pytorch/releases/tag/v2.2.0).

### Describe the solution you'd like
Update the requirements.

### Describe alternatives you've considered
N.A.

### Additional context
N.A.



Discussion:
Please assign this to me.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -71,7 +71,7 @@ def run(self):
 # specifying version for `black` separately because it is also used to [check for lint](https://github.com/mlcommons/GaNDLF/blob/master/.github/workflows/black.yml)
 black_version = "23.11.0"
 requirements = [
-    "torch==2.1.2",
+    "torch==2.2.1",
     f"black=={black_version}",
     "numpy==1.25.0",
     "scipy",
@@ -79,7 +79,7 @@ def run(self):
     "SimpleITK!=2.2.1",  # https://github.com/mlcommons/GaNDLF/issues/536
     "torchvision",
     "tqdm",
-    "torchio==0.19.5",
+    "torchio==0.19.6",
     "pandas>=2.0.0",
     "scikit-learn>=0.23.2",
     "scikit-image>=0.19.1",


Test patch:
Repository: mlcommons/GaNDLF

Issue:
[BUG] Noise and Blur enhanced fail for certain images
### Describe the bug
The variable blur and noise augmentations [[ref](https://github.com/mlcommons/GaNDLF/blob/master/GANDLF/data/augmentation/blur_enhanced.py),[ref](https://github.com/mlcommons/GaNDLF/blob/master/GANDLF/data/augmentation/noise_enhanced.py)] fail for certain images that do not have a float pixel type.

### To Reproduce
Steps to reproduce the behavior:
1. Use png data for training.
2. Use either of one of these 2 augmentations.
3. See error.

### Expected behavior
It should run. A simple fix is to add `image.data.float()` before calling `torch.std` for both.

### Media
N.A.

### Environment information
<!-- Put the output of the following command:
python ./gandlf_debugInfo
-->
N.A.

### Additional context
N.A.



Discussion:

Resolving patch:
diff --git a/GANDLF/data/augmentation/blur_enhanced.py b/GANDLF/data/augmentation/blur_enhanced.py
--- a/GANDLF/data/augmentation/blur_enhanced.py
+++ b/GANDLF/data/augmentation/blur_enhanced.py
@@ -52,5 +52,5 @@ def calculate_std_ranges(self, image: torch.Tensor) -> Tuple[float, float]:
         std_ranges = self.std_original
         if self.std_original is None:
             # calculate the default std range based on 1.5% of the input image std - https://github.com/mlcommons/GaNDLF/issues/518
-            std_ranges = (0, 0.015 * torch.std(image.data).item())
+            std_ranges = (0, 0.015 * torch.std(image.data.float()).item())
         return self.parse_params(std_ranges, None, "std", min_constraint=0)
diff --git a/GANDLF/data/augmentation/noise_enhanced.py b/GANDLF/data/augmentation/noise_enhanced.py
--- a/GANDLF/data/augmentation/noise_enhanced.py
+++ b/GANDLF/data/augmentation/noise_enhanced.py
@@ -66,5 +66,5 @@ def calculate_std_ranges(self, image: torch.Tensor) -> Tuple[float, float]:
         std_ranges = self.std_original
         if self.std_original is None:
             # calculate the default std range based on 1.5% of the input image std - https://github.com/mlcommons/GaNDLF/issues/518
-            std_ranges = (0, 0.015 * torch.std(image.data).item())
+            std_ranges = (0, 0.015 * torch.std(image.data.float()).item())
         return self._parse_range(std_ranges, "std", min_constraint=0)


Test patch: