class_docstr: Implements the TF backend ops for a PC auto-batching VM.
docstr: Backend hook for preparing Tensors for `cond`.
  
  The TensorFlow backend uses this hook to apply `tf.convert_to_tensor` before
  entering the cond tree generated by `virtual_machine._staged_apply`.  One
  could do this inside `cond`, but when this API element was defined there
  seemed to be a performance reason (for Eager mode) to do it once per cond
  tree rather than once per cond.
  
  Args:
    state: A state to be prepared for use in conditionals.
  
  Returns:
    state: The prepared state.
docstr_tok: ["Backend","hook","for","preparing","Tensors","for","`","cond","`",".","The","TensorFlow","backend","uses","this","hook","to","apply","`","tf.convert_to_tensor","`","before","entering","the","cond","tree","generated","by","`","virtual_machine._staged_apply","`",".","One","could","do","this","inside","`","cond","`",",","but","when","this","API","element","was","defined","there","seemed","to","be","a","performance","reason","(","for","Eager","mode",")","to","do","it","once","per","cond","tree","rather","than","once","per","cond",".","Args",":","state",":","A","state","to","be","prepared","for","use","in","conditionals",".","Returns",":","state",":","The","prepared","state","."]
code: def prepare_for_cond(self, state):
      """Backend hook for preparing Tensors for `cond`.
  
      The TensorFlow backend uses this hook to apply `tf.convert_to_tensor` before
      entering the cond tree generated by `virtual_machine._staged_apply`.  One
      could do this inside `cond`, but when this API element was defined there
      seemed to be a performance reason (for Eager mode) to do it once per cond
      tree rather than once per cond.
  
      Args:
        state: A state to be prepared for use in conditionals.
  
      Returns:
        state: The prepared state.
      """
      if tf.executing_eagerly():
          # Eager doesn't need to pre-wrap the cond-carried state at all.  Also, in
          # Eager, lazy initialization for register variables means that the state
          # may not always be correct to convert to a Tensor.
          return state
      with tf.name_scope("VM.prepare_for_cond"):
          state_flat = [
              tf.convert_to_tensor(value=x)
              for x in tf.nest.flatten(state)
          ]
          return tf.nest.pack_sequence_as(state, state_flat)
  
imports: import collections
  import contextlib
  import six
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.experimental.auto_batching import instructions
  from tensorflow_probability.python.experimental.auto_batching import xla
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow.python.ops import control_flow_util
label_desc: Use image node_id 15 for calling the TensorFlowBackend obj's underlying member method code with example usage: obj.prepare_for_cond(state) and returns: state, tf