code: def direction_neuron_cossim_S(
      layer_name, vec, batch=None, x=None, y=None, cossim_pow=2, S=None
  ):
      def inner(T):
          layer = T(layer_name)
          shape = tf.shape(layer)
          x_ = shape[1] // 2 if x is None else x
          y_ = shape[2] // 2 if y is None else y
          if batch is None:
              raise RuntimeError("requires batch")
  
          acts = layer[batch, x_, y_]
          vec_ = vec
          if S is not None:
              vec_ = tf.matmul(vec_[None], S)[0]
          mag = tf.sqrt(tf.reduce_sum(acts**2))
          dot = tf.reduce_mean(acts * vec_)
          cossim = dot / (1e-4 + mag)
          cossim = tf.maximum(0.1, cossim)
          return dot * cossim**cossim_pow
  
      return inner
  
file_path: lucid/lucid/recipes/activation_atlas/render.py
imports: from __future__ import absolute_import, division, print_function
  import tensorflow
  import numpy
  from itertools import chain
  import lucid.optvis.objectives
  import lucid.optvis.param
  import lucid.optvis.render
  import lucid.optvis.transform
label_desc: Use image node_id 2 for calling a global function with example usage: direction_neuron_cossim_S(layer_name, vec, batch, x, y, cossim_pow, S) and returns: inner, unknown