code: def test_pytorch_multiple_inputs(torch_device, disconnected):
      """Check a multi-input scenario."""
      torch = pytest.importorskip("torch")
  
      from sklearn.datasets import fetch_california_housing
      from torch import nn
      from torch.nn import functional as F
      from torch.utils.data import DataLoader, TensorDataset
  
      class Net(nn.Module):
          """Testing model."""
  
          def __init__(self, num_features, disconnected):
              super().__init__()
              self.disconnected = disconnected
              if disconnected:
                  num_features = num_features // 2
              self.linear = nn.Linear(num_features, 2)
              self.output = nn.Sequential(nn.MaxPool1d(2), nn.ReLU())
  
          def forward(self, x1, x2):
              """Run the model."""
              if self.disconnected:
                  x = self.linear(x1).unsqueeze(1)
              else:
                  x = self.linear(
                      torch.cat((x1, x2), dim=-1)
                  ).unsqueeze(1)
              return self.output(x).squeeze(1)
  
      def train(model, device, train_loader, optimizer, epoch):
          model.train()
          num_examples = 0
          for batch_idx, (data1, data2, target) in enumerate(
              train_loader
          ):
              num_examples += target.shape[0]
              data1, data2, target = (
                  data1.to(device),
                  data2.to(device),
                  target.to(device),
              )
              optimizer.zero_grad()
              output = model(data1, data2)
              loss = F.mse_loss(output.squeeze(1), target)
              loss.backward()
              optimizer.step()
              if batch_idx % 2 == 0:
                  print(
                      "Train Epoch: {} [{}/{} ({:.0f}%)]\tLoss: {:.6f}".format(
                          epoch,
                          batch_idx * len(data),
                          len(train_loader.dataset),
                          100.0 * batch_idx / len(train_loader),
                          loss.item(),
                      )
                  )
  
      random_seed = 42  # TODO: 2960
      torch.manual_seed(random_seed)
      rs = np.random.RandomState(random_seed)
  
      X, y = fetch_california_housing(return_X_y=True)
  
      num_features = X.shape[1]
      x1 = X[:, num_features // 2 :]
      x2 = X[:, : num_features // 2]
  
      data = TensorDataset(
          torch.tensor(x1).float(),
          torch.tensor(x2).float(),
          torch.tensor(y).float(),
      )
  
      loader = DataLoader(data, batch_size=128)
  
      model = Net(num_features, disconnected)
      optimizer = torch.optim.Adam(model.parameters())
  
      device = torch.device(torch_device)
  
      model.to(device)
  
      train(model, device, loader, optimizer, 1)
  
      next_x1, next_x2, _ = next(iter(loader))
      inds = rs.choice(next_x1.shape[0], 20, replace=False)
      background = [
          next_x1[inds, :].to(device),
          next_x2[inds, :].to(device),
      ]
      e = shap.DeepExplainer(model, background)
  
      test_x1_tmp, test_x2_tmp, _ = next(iter(loader))
      test_x1 = test_x1_tmp[:1].to(device)
      test_x2 = test_x2_tmp[:1].to(device)
  
      shap_x1, shap_x2 = e.shap_values([test_x1[:1], test_x2[:1]])
  
      model.eval()
      model.zero_grad()
  
      with torch.no_grad():
          diff = (
              (model(test_x1, test_x2[:1]) - model(*background))
              .detach()
              .cpu()
              .numpy()
              .mean(0)
          )
  
      sums = np.array(
          [
              shap_x1[i].sum() + shap_x2[i].sum()
              for i in range(len(shap_x1))
          ]
      )
      d = np.abs(sums - diff).sum() / np.abs(diff).sum()
  
      assert (
          d < 0.001
      ), f"Sum of SHAP values does not match difference! {d}"
  
file_path: shap/tests/explainers/test_deep.py
imports: import numpy
  import pandas
  import pytest
  from packaging import version
  import shap
  from shap import DeepExplainer
label_desc: Use image node_id 9 for calling a global function with example usage: test_pytorch_multiple_inputs(torch_device, disconnected) and returns: self