def get_logits_and_probs(logits=None,<EOL>probs=None,<EOL>multidimensional=False,<EOL>validate_args=False,<EOL>name="<STR_LIT>",<EOL>dtype=None):
if dtype is None:<EOL><INDENT>dtype = dtype_util.common_dtype([probs, logits], preferred_dtype=tf.float32)<EOL><DEDENT>with tf.name_scope(name):<EOL><INDENT>if (probs is None) == (logits is None):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if probs is None:<EOL><INDENT>logits = tf.convert_to_tensor(value=logits, name="<STR_LIT>", dtype=dtype)<EOL>if not dtype_util.is_floating(logits.dtype):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if multidimensional:<EOL><INDENT>if validate_args:<EOL><INDENT>logits = embed_check_categorical_event_shape(logits)<EOL><DEDENT>return logits, tf.nn.softmax(logits, name="<STR_LIT>")<EOL><DEDENT>return logits, tf.sigmoid(logits, name="<STR_LIT>")<EOL><DEDENT>probs = tf.convert_to_tensor(value=probs, name="<STR_LIT>", dtype=dtype)<EOL>if not dtype_util.is_floating(probs.dtype):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if validate_args:<EOL><INDENT>with tf.name_scope("<STR_LIT>"):<EOL><INDENT>one = tf.constant(<NUM_LIT:1.>, probs.dtype)<EOL>dependencies = [assert_util.assert_non_negative(probs)]<EOL>if multidimensional:<EOL><INDENT>probs = embed_check_categorical_event_shape(probs)<EOL>dependencies += [<EOL>assert_util.assert_near(<EOL>tf.reduce_sum(input_tensor=probs, axis=-<NUM_LIT:1>),<EOL>one,<EOL>message="<STR_LIT>")<EOL>]<EOL><DEDENT>else:<EOL><INDENT>dependencies += [<EOL>assert_util.assert_less_equal(<EOL>probs, one, message="<STR_LIT>")<EOL>]<EOL><DEDENT>probs = with_dependencies(dependencies, probs)<EOL><DEDENT><DEDENT>with tf.name_scope("<STR_LIT>"):<EOL><INDENT>if multidimensional:<EOL><INDENT>return tf.math.log(probs), probs<EOL><DEDENT>return tf.math.log(probs) - tf.math.log1p(-<NUM_LIT:1.> * probs), probs<EOL><DEDENT><DEDENT>
Converts logit to probabilities (or vice-versa), and returns both.

    Args:
      logits: Floating-point `Tensor` representing log-odds.
      probs: Floating-point `Tensor` representing probabilities.
      multidimensional: Python `bool`, default `False`. If `True`, represents
        whether the last dimension of `logits` or `probs`, a `[N1, N2, ...  k]`
        dimensional tensor, representing the logit or probability of `shape[-1]`
        classes.
      validate_args: Python `bool`, default `False`. When `True`, either assert `0
        <= probs <= 1` (if not `multidimensional`) or that the last dimension of
        `probs` sums to one.
      name: A name for this operation (optional).
      dtype: `tf.DType` to prefer when converting args to `Tensor`s.

    Returns:
      logits, probs: Tuple of `Tensor`s. If `probs` has an entry that is `0` or
        `1`, then the corresponding entry in the returned logit will be `-Inf` and
        `Inf` respectively.

    Raises:
      ValueError: if neither `probs` nor `logits` were passed in, or both were.