code: def test_binary_predictions(
      tmpdir, backend, distinct_values, ray_cluster_2cpu
  ):
      input_features = [
          category_feature(encoder={"vocab_size": 3}),
      ]
  
      feature = binary_feature()
      output_features = [
          feature,
      ]
  
      data_csv_path = generate_data(
          input_features,
          output_features,
          os.path.join(tmpdir, "dataset.csv"),
          num_examples=100,
      )
      data_df = pd.read_csv(data_csv_path)
  
      # Optionally convert bool values to strings, e.g., {'Yes', 'No'}
      false_value, true_value = distinct_values
      data_df[feature[NAME]] = data_df[feature[NAME]].map(
          lambda x: true_value if x else false_value
      )
      data_df.to_csv(data_csv_path, index=False)
  
      config = {
          "input_features": input_features,
          "output_features": output_features,
          TRAINER: {"epochs": 1, BATCH_SIZE: 128},
      }
  
      patch_args = (
          "ludwig.features.binary_feature.BinaryOutputFeature.logits",
          partial(
              random_binary_logits, num_predict_samples=len(data_df)
          ),
      )
  
      preds_df, _ = predict_with_backend(
          tmpdir, config, data_csv_path, backend, patch_args=patch_args
      )
      cols = set(preds_df.columns)
      assert f"{feature[NAME]}_predictions" in cols
      assert f"{feature[NAME]}_probabilities_{str(false_value)}" in cols
      assert f"{feature[NAME]}_probabilities_{str(true_value)}" in cols
      assert f"{feature[NAME]}_probability" in cols
  
      for pred, prob_0, prob_1, prob in zip(
          preds_df[f"{feature[NAME]}_predictions"],
          preds_df[f"{feature[NAME]}_probabilities_{str(false_value)}"],
          preds_df[f"{feature[NAME]}_probabilities_{str(true_value)}"],
          preds_df[f"{feature[NAME]}_probability"],
      ):
          assert pred == false_value or pred == true_value
          if pred == true_value:
              assert prob_1 == prob
          else:
              assert prob_0 == prob
          assert np.allclose(prob_0, 1 - prob_1)
  
file_path: ludwig/tests/integration_tests/test_postprocessing.py
imports: import os
  from functools import partial
  from unittest import mock
  import numpy
  import pandas
  import pytest
  import torch
  from ludwig.api import LudwigModel
  from ludwig.constants import BATCH_SIZE, DECODER, NAME, TRAINER
  from tests.integration_tests.utils import binary_feature, category_feature, generate_data, RAY_BACKEND_CONFIG, set_feature, text_feature
label_desc: Use image node_id 3 for calling a global function with example usage: test_binary_predictions(tmpdir, backend, distinct_values, ray_cluster_2cpu) without return types