prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Bug during saving probabilities
  **Describe the bug**
  Small bug is occurring during saving probabilities in classification tasks. This is due to file existence check. It should check if the file exists instead of checking if the directory exists.
  
  
  </issue>
  <code>
  [start of GANDLF/inference_manager.py]
  1 from GANDLF.inference_loop import inference_loop
  2 import os
  3 import numpy as np
  4 import torch
  5 import torch.nn.functional as F
  6 
  7 
  8 def InferenceManager(dataframe, outputDir, parameters, device):
  9     """
  10     This function takes in a dataframe, with some other parameters and performs the inference
  11     """
  12     # get the indeces for kfold splitting
  13     inferenceData_full = dataframe
  14 
  15     # # initialize parameters for inference
  16     if not ("weights" in parameters):
  17         parameters["weights"] = None  # no need for loss weights for inference
  18     if not ("class_weights" in parameters):
  19         parameters["class_weights"] = None  # no need for class weights for inference
  20 
  21     n_folds = parameters["nested_training"]["validation"]
  22 
  23     fold_dirs = []
  24     if n_folds > 1:
  25         directories = sorted(os.listdir(outputDir))
  26         for d in directories:
  27             if d.isdigit():
  28                 fold_dirs.append(os.path.join(outputDir, d, ""))
  29     else:
  30         fold_dirs = [outputDir]
  31 
  32     probs_list = []
  33 
  34     is_classification = parameters["problem_type"] == "classification"
  35 
  36     for fold_dir in fold_dirs:
  37         parameters["current_fold_dir"] = fold_dir
  38         inference_loop(
  39             inferenceDataFromPickle=inferenceData_full,
  40             outputDir=fold_dir,
  41             device=device,
  42             parameters=parameters,
  43         )
  44 
  45         logits_dir = os.path.join(fold_dir, "logits.csv")
  46         is_logits_dir_exist = os.path.isdir(logits_dir)
  47 
  48         if is_classification and is_logits_dir_exist:
  49             fold_logits = np.genfromtxt(logits_dir, delimiter=",")
  50             fold_logits = torch.from_numpy(fold_logits)
  51             fold_probs = F.softmax(fold_logits, dim=1)
  52             probs_list.append(fold_probs)
  53 
  54     if probs_list and is_classification:
  55         probs_list = torch.stack(probs_list)
  56         averaged_probs = torch.mean(probs_list, 0).numpy()
  57         np.savetxt(
  58             os.path.join(outputDir, "averaged_probabilities.csv"),
  59             averaged_probs,
  60             delimiter=",",
  61         )
  62 
  63
  [end of GANDLF/inference_manager.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/GANDLF/inference_manager.py b/GANDLF/inference_manager.py
  --- a/GANDLF/inference_manager.py
  +++ b/GANDLF/inference_manager.py
  @@ -43,7 +43,7 @@
           )
   
           logits_dir = os.path.join(fold_dir, "logits.csv")
  -        is_logits_dir_exist = os.path.isdir(logits_dir)
  +        is_logits_dir_exist = os.path.isfile(logits_dir)
   
           if is_classification and is_logits_dir_exist:
               fold_logits = np.genfromtxt(logits_dir, delimiter=",")
  
verification_info: {"golden_diff": "diff --git a/GANDLF/inference_manager.py b/GANDLF/inference_manager.py\n--- a/GANDLF/inference_manager.py\n+++ b/GANDLF/inference_manager.py\n@@ -43,7 +43,7 @@\n         )\n \n         logits_dir = os.path.join(fold_dir, \"logits.csv\")\n-        is_logits_dir_exist = os.path.isdir(logits_dir)\n+        is_logits_dir_exist = os.path.isfile(logits_dir)\n \n         if is_classification and is_logits_dir_exist:\n             fold_logits = np.genfromtxt(logits_dir, delimiter=\",\")\n", "issue": "Bug during saving probabilities\n**Describe the bug**\r\nSmall bug is occurring during saving probabilities in classification tasks. This is due to file existence check. It should check if the file exists instead of checking if the directory exists.\r\n\n", "before_files": [{"content": "from GANDLF.inference_loop import inference_loop\nimport os\nimport numpy as np\nimport torch\nimport torch.nn.functional as F\n\n\ndef InferenceManager(dataframe, outputDir, parameters, device):\n    \"\"\"\n    This function takes in a dataframe, with some other parameters and performs the inference\n    \"\"\"\n    # get the indeces for kfold splitting\n    inferenceData_full = dataframe\n\n    # # initialize parameters for inference\n    if not (\"weights\" in parameters):\n        parameters[\"weights\"] = None  # no need for loss weights for inference\n    if not (\"class_weights\" in parameters):\n        parameters[\"class_weights\"] = None  # no need for class weights for inference\n\n    n_folds = parameters[\"nested_training\"][\"validation\"]\n\n    fold_dirs = []\n    if n_folds > 1:\n        directories = sorted(os.listdir(outputDir))\n        for d in directories:\n            if d.isdigit():\n                fold_dirs.append(os.path.join(outputDir, d, \"\"))\n    else:\n        fold_dirs = [outputDir]\n\n    probs_list = []\n\n    is_classification = parameters[\"problem_type\"] == \"classification\"\n\n    for fold_dir in fold_dirs:\n        parameters[\"current_fold_dir\"] = fold_dir\n        inference_loop(\n            inferenceDataFromPickle=inferenceData_full,\n            outputDir=fold_dir,\n            device=device,\n            parameters=parameters,\n        )\n\n        logits_dir = os.path.join(fold_dir, \"logits.csv\")\n        is_logits_dir_exist = os.path.isdir(logits_dir)\n\n        if is_classification and is_logits_dir_exist:\n            fold_logits = np.genfromtxt(logits_dir, delimiter=\",\")\n            fold_logits = torch.from_numpy(fold_logits)\n            fold_probs = F.softmax(fold_logits, dim=1)\n            probs_list.append(fold_probs)\n\n    if probs_list and is_classification:\n        probs_list = torch.stack(probs_list)\n        averaged_probs = torch.mean(probs_list, 0).numpy()\n        np.savetxt(\n            os.path.join(outputDir, \"averaged_probabilities.csv\"),\n            averaged_probs,\n            delimiter=\",\",\n        )\n\n", "path": "GANDLF/inference_manager.py"}]}