class_docstr: Value approximation objective, which minimizes the L2-distance between the state-(action-)value
  estimate and the target reward value
  (specification key: `value`, `state_value`, `action_value`).
  
  Args:
      value ("state" | "action"): Whether to approximate the state- or state-action-value
          (<span style="color:#C00000"><b>required</b></span>).
      huber_loss (parameter, float > 0.0): Huber loss threshold
          (<span style="color:#00C000"><b>default</b></span>: no huber loss).
      early_reduce (bool): Whether to compute objective for aggregated value instead of value per
          action (<span style="color:#00C000"><b>default</b></span>: true).
      name (string): <span style="color:#0000C0"><b>internal use</b></span>.
      states_spec (specification): <span style="color:#0000C0"><b>internal use</b></span>.
      internals_spec (specification): <span style="color:#0000C0"><b>internal use</b></span>.
      auxiliaries_spec (specification): <span style="color:#0000C0"><b>internal use</b></span>.
      actions_spec (specification): <span style="color:#0000C0"><b>internal use</b></span>.
      reward_spec (specification): <span style="color:#0000C0"><b>internal use</b></span>.
code: def loss(
      self,
      *,
      states,
      horizons,
      internals,
      auxiliaries,
      actions,
      reward,
      reference,
      policy,
      baseline=None,
  ):
      # value = self.reference(
      #     states=states, horizons=horizons, internals=internals, auxiliaries=auxiliaries,
      #     actions=actions, policy=policy
      # )
  
      # reference = tf.stop_gradient(input=reference)
  
      if self.value == "state":
          if self.early_reduce:
              value = policy.state_value(
                  states=states,
                  horizons=horizons,
                  internals=internals,
                  auxiliaries=auxiliaries,
              )
          else:
              value = policy.state_values(
                  states=states,
                  horizons=horizons,
                  internals=internals,
                  auxiliaries=auxiliaries,
              )
              value = tf.concat(values=tuple(value.values()), axis=1)
  
      elif self.value == "action":
          if self.early_reduce:
              value = policy.action_value(
                  states=states,
                  horizons=horizons,
                  internals=internals,
                  auxiliaries=auxiliaries,
                  actions=actions,
              )
          else:
              value = policy.action_values(
                  states=states,
                  horizons=horizons,
                  internals=internals,
                  auxiliaries=auxiliaries,
                  actions=actions,
              )
              value = tf.concat(values=tuple(value.values()), axis=1)
  
      if not self.early_reduce:
          reward = tf.expand_dims(input=reward, axis=1)
  
      difference = value - reward
  
      half = tf_util.constant(value=0.5, dtype="float")
  
      if self.huber_loss is None:
          loss = half * tf.math.square(x=difference)
  
      else:
          huber_loss = self.huber_loss.value()
          inside_huber_bounds = tf.math.less_equal(
              x=tf.math.abs(x=difference), y=huber_loss
          )
          quadratic = half * tf.math.square(x=difference)
          linear = huber_loss * (
              tf.math.abs(x=difference) - half * huber_loss
          )
          loss = tf.where(
              condition=inside_huber_bounds, x=quadratic, y=linear
          )
  
      if not self.early_reduce:
          loss = tf.math.reduce_sum(input_tensor=loss, axis=1)
  
      return loss
  
file_path: tensorforce/tensorforce/core/objectives/value.py
imports: import tensorflow
  from tensorforce.core import parameter_modules, TensorSpec, tf_function, tf_util
  from tensorforce.core.objectives import Objective
label_desc: Use image node_id 5 for calling the Value obj's underlying member method code with example usage: obj.loss() and returns: loss