code: def get_multi_path_attr(
      model,
      layer_name,
      prev_layer_name,
      obses,
      prev_nmf,
      *,
      act_dir=None,
      act_poses=None,
      score_fn=default_score_fn,
      override=None,
      max_paths=50,
      integrate_steps=10,
  ):
      with tf.Graph().as_default(), tf.Session(), gradient_override_map(
          override or {}
      ):
          t_obses = tf.placeholder_with_default(
              obses.astype(np.float32), (None, None, None, None)
          )
          T = render.import_model(model, t_obses, t_obses)
          t_acts = T(layer_name)
          if prev_layer_name is None:
              t_acts_prev = t_obses
          else:
              t_acts_prev = T(prev_layer_name)
          if act_dir is not None:
              t_acts = act_dir[None, None, None] * t_acts
          if act_poses is not None:
              t_acts = tf.gather_nd(
                  t_acts,
                  tf.concat(
                      [tf.range(obses.shape[0])[..., None], act_poses],
                      axis=-1,
                  ),
              )
          t_scores = score_fn(t_acts)
          assert (
              len(t_scores.shape) >= 1
          ), "score_fn should not reduce the batch dim"
          t_score = tf.reduce_sum(t_scores)
          t_grad = tf.gradients(t_score, [t_acts_prev])[0]
          acts_prev = t_acts_prev.eval()
          path_acts = get_paths(
              acts_prev,
              prev_nmf,
              max_paths=max_paths,
              integrate_steps=integrate_steps,
          )
          deltas_of_path = lambda path: np.array(
              [
                  b - a
                  for a, b in zip(
                      [np.zeros_like(acts_prev)] + path[:-1], path
                  )
              ]
          )
          grads_of_path = lambda path: np.array(
              [
                  t_grad.eval(feed_dict={t_acts_prev: acts})
                  for acts in path
              ]
          )
          path_attrs = map(
              lambda path: (
                  deltas_of_path(path) * grads_of_path(path)
              ).sum(axis=0),
              path_acts,
          )
          total_attr = 0
          num_paths = 0
          for attr in path_attrs:
              total_attr += attr
              num_paths += 1
          return total_attr / num_paths
  
file_path: lucid/lucid/scratch/rl_util/attribution.py
imports: import numpy
  import tensorflow
  import lucid.optvis.render
  import itertools
  from lucid.misc.gradient_override import gradient_override_map
label_desc: Use image node_id 8 for calling a global function with example usage: get_multi_path_attr(model, layer_name, prev_layer_name, obses, prev_nmf) and returns: unknown