class_docstr: Bernoulli distribution, for binary boolean actions (specification key: `bernoulli`).
  
  Args:
      name (string): <span style="color:#0000C0"><b>internal use</b></span>.
      action_spec (specification): <span style="color:#0000C0"><b>internal use</b></span>.
      input_spec (specification): <span style="color:#0000C0"><b>internal use</b></span>.
class_docstr_tok: ["Bernoulli","distribution",",","for","binary","boolean","actions","(","specification","key",":","`","bernoulli","`",")",".","Args",":","name","(","string",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">",".","action_spec","(","specification",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">",".","input_spec","(","specification",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">","."]
code: def sample(self, *, parameters, temperature, independent):
      true_logit, false_logit, probability = parameters.get(
          ("true_logit", "false_logit", "probability")
      )
  
      # Distribution parameter summaries
      dependencies = list()
      if not independent:
  
          def fn_summary():
              axis = range(self.action_spec.rank + 1)
              return tf.math.reduce_mean(
                  input_tensor=probability, axis=axis
              )
  
          name = "distributions/" + self.name + "-probability"
          dependencies.extend(
              self.summary(
                  label="distribution",
                  name=name,
                  data=fn_summary,
                  step="timesteps",
              )
          )
  
      # Distribution parameter tracking
      def fn_tracking():
          return tf.math.reduce_mean(input_tensor=probability, axis=0)
  
      dependencies.extend(
          self.track(
              label="distribution", name="probability", data=fn_tracking
          )
      )
  
      epsilon = tf_util.constant(value=util.epsilon, dtype="float")
  
      def fn_mode():
          # Deterministic: true if >= 0.5
          half = tf_util.constant(value=0.5, dtype="float")
          return tf.greater_equal(x=probability, y=half)
  
      def fn_sample():
          # Non-deterministic: sample true if >= uniform distribution
          # Exp numerically stable since logits <= 0.0
          e_true_logit = tf.math.exp(
              x=(true_logit / (temperature + epsilon))
          )
          e_false_logit = tf.math.exp(
              x=(false_logit / (temperature + epsilon))
          )
          probability = e_true_logit / (
              e_true_logit + e_false_logit + epsilon
          )
          uniform = tf.random.uniform(
              shape=tf.shape(input=probability),
              dtype=tf_util.get_dtype(type="float"),
          )
          return tf.greater_equal(x=probability, y=uniform)
  
      with tf.control_dependencies(control_inputs=dependencies):
          return tf.cond(
              pred=(temperature < epsilon),
              true_fn=fn_mode,
              false_fn=fn_sample,
          )
  
file_path: tensorforce/tensorforce/core/distributions/bernoulli.py
imports: import tensorflow
  from tensorforce import TensorforceError, util
  from tensorforce.core import layer_modules, TensorDict, TensorSpec, TensorsSpec, tf_function, tf_util
  from tensorforce.core.distributions import Distribution
label_desc: Use image node_id 6 for calling the Bernoulli obj's underlying member method code with example usage: obj.sample() and returns: tf, tf, tf, tf, tf