message: Add a hopefully more helpful error msg when some boolean mirrored variable is used in TF 1.x control flows.
diff: @@ -893,7 +893,13 @@ class MirroredVariable(DistributedVariable, Mirrored):
  """Converts a variable to a tensor."""
  # Try to avoid assignments to and other mutations of MirroredVariable
  # state except through a DistributionStrategy.extended.update() call.
  - assert not as_ref
  + if as_ref:
  + # A TF 1.x case where the variable is a boolean variable and used like:
  + # tf.cond(v, true_fn, false_fn).
  + raise ValueError(
  + "You may be using variable created under distribute strategy in TF "
  + "1.x control flows. Try explicitly converting the variable to Tensor "
  + "using variable.read_value(), or switch to TF 2.x.")
  return ops.convert_to_tensor(
  self._get(), dtype=dtype, name=name, as_ref=as_ref)
  