code: def shape_list(x):
    
    x = tf.convert_to_tensor(x)
  
    # If unknown rank, return dynamic shape
    if x.get_shape().dims is None:
      return tf.shape(x)
  
    static = x.get_shape().as_list()
    shape = tf.shape(x)
  
    ret = []
    for i, dim in enumerate(static):
      if dim is None:
        dim = shape[i]
      ret.append(dim)
    return ret
docs: Return list of dims, statically where possible.