code: def tensor_direction(layer, vec, cossim_pow=0, batch=None):
      """Visualize a tensor."""
      assert len(vec.shape) in [3, 4]
      vec = vec.astype("float32")
      if len(vec.shape) == 3:
          vec = vec[None]
  
      @handle_batch(batch)
      def inner(T):
          t_acts = T(layer)
          t_shp = tf.shape(t_acts)
          v_shp = vec.shape
          M1 = (t_shp[1] - v_shp[1]) // 2
          M2 = (t_shp[2] - v_shp[2]) // 2
          t_acts_ = t_acts[:, M1 : M1 + v_shp[1], M2 : M2 + v_shp[2], :]
          return _dot_cossim(t_acts_, vec, cossim_pow=cossim_pow)
  
      return inner
  
imports: from __future__ import absolute_import, division, print_function
  from decorator import decorator
  import numpy
  import tensorflow
  from lucid.optvis.objectives_util import _dot, _dot_cossim, _extract_act_pos, _make_arg_str, _T_force_NHWC, _T_handle_batch
label_desc: Use image node_id 7 for calling a global function with example usage: tensor_direction(layer, vec, cossim_pow, batch) and returns: inner, _dot_cossim