import tensorflow as tf

    x_duplicate_sample = x_duplicate.sample(name="custom_sample")

    self.assertEqual(x.name, "x/")
    self.assertEqual(y.name, "y/")

    # There's no notion of graph, hence the same name will be reused.
    # Tensors also do not have names in eager mode, so exit early.
    if tf.executing_eagerly():
      return
    self.assertTrue(x_sample.name.startswith("x/custom_sample"))
    self.assertTrue(x_log_prob.name.startswith("x/custom_log_prob"))

    self.assertEqual(x_duplicate.name, "x_1/")
    self.assertTrue(x_duplicate_sample.name.startswith(
