code: def layer_conductance(net, test_input_tensor):
      """
      To use Layer Conductance, we create a LayerConductance object passing in the model as well as the module (layer) whose output we would like to understand.
      In this case, we choose net.sigmoid1, the output of the first hidden layer.
      Now obtain the conductance values for all the test examples by calling attribute on the LayerConductance object.
      LayerConductance also requires a target index for networks with multiple outputs, defining the index of the output for which gradients are computed.
      Similar to feature attributions, we provide target = 1, corresponding to survival.
      LayerConductance also utilizes a baseline, but we simply use the default zero baseline as in integrated gradients.
      """
  
      cond = LayerConductance(net, net.sigmoid1)
  
      cond_vals = cond.attribute(test_input_tensor, target=1)
      cond_vals = cond_vals.detach().numpy()
      # We can begin by visualizing the average conductance for each neuron.
      neuron_names = ["neuron " + str(x) for x in range(12)]
      avg_neuron_imp, neuron_imp_dict = visualize_importances(
          neuron_names,
          np.mean(cond_vals, axis=0),
          title="Average Neuron Importances",
          axis_title="Neurons",
      )
      mlflow.log_metrics(neuron_imp_dict)
      mlflow.log_text(str(avg_neuron_imp), "neuron_imp_summary.txt")
      # We can also look at the distribution of each neuron's attributions. Below we look at the distributions for neurons 7 and 9,
      # and we can confirm that their attribution distributions are very close to 0, suggesting they are not learning substantial features.
      fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(9, 6))
      fig.tight_layout(pad=3)
      ax1.hist(cond_vals[:, 9], 100)
      ax1.set(title="Neuron 9 Distribution")
      ax2.hist(cond_vals[:, 7], 100)
      ax2.set(title="Neuron 7 Distribution")
      mlflow.log_figure(fig, "Neurons_Distribution.png")
  
imports: import os
  from argparse import ArgumentParser
  import matplotlib.pyplot
  import numpy
  import pandas
  import torch
  from captum.attr import IntegratedGradients, LayerConductance, NeuronConductance
  from prettytable import PrettyTable
  from scipy import stats
  from sklearn.model_selection import train_test_split
  from torch import nn
  import mlflow
label_desc: Use image node_id 8 for calling a global function with example usage: layer_conductance(net, test_input_tensor) without return types