code: def test_sensr_regression():
      """Tests whether SenSR output matches original implementation."""
      X, y = make_regression(n_features=10)
      X, y = X.astype("float32"), y.astype("float32").reshape(-1, 1)
      ds = Dataset(X, y)
  
      dx = distances.MahalanobisDistances()
      dx.fit(torch.eye(10))
  
      torch.random.manual_seed(0)
      mlp = nn.Sequential(
          nn.Linear(10, 100), nn.ReLU(), nn.Linear(100, 1)
      )
      aif360_sensei = SenSR(
          mlp,
          criterion=nn.MSELoss,
          distance_x=dx,
          eps=0.1,
          lr_lamb=1.0,
          lr_param=1.0,
          auditor_nsteps=10,
          auditor_lr=0.01,
          max_epochs=5,
          optimizer=optim.Adam,
          lr=1e-3,
          predict_nonlinearity=None,
          verbose=0,
      )
      y_pred = aif360_sensei.fit(X, y).predict(X)
      assert aif360_sensei.regression_ == True
  
      torch.random.manual_seed(0)
      mlp = nn.Sequential(
          nn.Linear(10, 100), nn.ReLU(), nn.Linear(100, 1)
      )
      orig_sensei = fairalgo.SenSR(
          mlp, dx, F.mse_loss, 0.1, 1.0, 1.0, 10, 0.01
      )
      orig_sensei.train()
      opt = optim.Adam(orig_sensei.parameters(), lr=1e-3)
      for _ in range(5):
          opt.zero_grad()
          batch = next(
              iter(torch.utils.data.DataLoader(ds, batch_size=len(ds)))
          )
          loss = orig_sensei(*batch).loss
          loss.backward()
          opt.step()
      orig_sensei.eval()
      y_pred_orig = (
          orig_sensei(torch.as_tensor(X), torch.as_tensor(y))
          .y_pred.detach()
          .numpy()
      )
  
      assert np.allclose(y_pred, y_pred_orig)
  
file_path: AIF360/tests/sklearn/test_infairness.py
imports: from contextlib import nullcontext
  from functools import partial
  from inFairness import fairalgo, distances
  import numpy
  import pandas
  import pytest
  from sklearn.datasets import make_classification, make_regression
  from sklearn.model_selection import GridSearchCV
  from sklearn.pipeline import Pipeline
  from sklearn.preprocessing import StandardScaler
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  from aif360.sklearn.inprocessing import SenSeI, SenSR
  from aif360.sklearn.inprocessing.infairness import Dataset
label_desc: Use image node_id 2 for calling a global function with example usage: test_sensr_regression() without return types