code: def shape_slice(x, slice_):
      """Equivalent to `shape(x)[slice_]`, but robust to partially-known shapes."""
      x_shape = x.shape
  
      def _static(val):
          if val is None:
              # slice components are very commonly None, which indicates a static choice
              # of the, e.g., slice end point.
              return val, True
          else:
              val = tf.get_static_value(val)
              return val, val is not None
  
      static_start, start_is_static = _static(slice_.start)
      static_stop, stop_is_static = _static(slice_.stop)
      static_step, step_is_static = _static(slice_.step)
  
      if all([start_is_static, stop_is_static, step_is_static]):
          slice_ = _slice(static_start, static_stop, static_step)
          res = x_shape[slice_]
          if tensorshape_util.is_fully_defined(res):
              return tensorshape_util.as_list(res)
          x_shape = _shape(x)
      else:
          x_shape = convert_to_shape_tensor(_shape(x))
      return x_shape[slice_]
  
imports: import decorator
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal.backend import numpy
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.ops import control_flow_case
  from tensorflow.python.util import tf_inspect
label_desc: Use image node_id 15 for calling a global function with example usage: shape_slice(x, slice_) and returns: x_shape, val,  True, val,  unknown, tensorshape_util