def test_shape_mixed(self):
    """Test for shape() with a mixture of static and dynamic sizes."""
    with tf.Graph().as_default():
      tensor = tf.placeholder(tf.int64, [4, None])
      d0_single = tensor_utils.shape(tensor, 0)
      d1_single = tensor_utils.shape(tensor, 1)
      d0_full, d1_full = tensor_utils.shape(tensor)

      self.assertIsInstance(d0_single, int)
      self.assertIsInstance(d1_single, tf.Tensor)
      self.assertIsInstance(d0_full, int)
      self.assertIsInstance(d1_full, tf.Tensor)

      self.assertEqual(d0_single, 4)
      self.assertEqual(d0_full, 4)

      with tf.Session() as sess:
        feed_dict = {tensor: np.zeros((4, 7))}

        tf_d1_single = sess.run(d1_single, feed_dict=feed_dict)
        self.assertEqual(tf_d1_single, 7)

        tf_d1_full = sess.run(d1_full, feed_dict=feed_dict)
        self.assertEqual(tf_d1_full, 7)
Test for shape() with a mixture of static and dynamic sizes.
language/common/utils/tensor_utils_test.py