code: def get_state_shape_invariants(tensor):
      """Returns the shape of the tensor but sets middle dims to None."""
      shape = tensor.shape.as_list()
      for i in range(1, len(shape) - 1):
          shape[i] = None
      return tf.TensorShape(shape)
  
file_path: finetune/finetune/util/beam_search.py
imports: import math
  import numpy
  from finetune.util.shapes import shape_list
  import tensorflow
  from tensorflow.python.ops import inplace_ops
  from tensorflow.python.util import nest
label_desc: Use image node_id 7 for calling a global function with example usage: get_state_shape_invariants(tensor) and returns: tf