<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def direction(layer, vec, batch=None, cossim_pow=0):
 """Visualize a direction"""

  if batch is None:
    vec = vec[None, None, None]
    return lambda T: _dot_cossim(T(layer), vec)
  else:
    vec = vec[None, None]
    return lambda T: _dot_cossim(T(layer)[batch], vec)