code: def loss(
      self,
      *,
      states,
      horizons,
      internals,
      auxiliaries,
      actions,
      reward,
      reference,
  ):
      if self.baseline_optimizer is None:
          policy_internals = internals["policy"]
      else:
          policy_internals = internals
      if (
          self.baseline_objective is not None
          and self.baseline_loss_weight is not None
          and not self.baseline_loss_weight.is_constant(value=0.0)
      ):
          policy_reference = reference["policy"]
      else:
          policy_reference = reference
  
      # Loss per instance
      loss = self.objective.loss(
          states=states,
          horizons=horizons,
          internals=policy_internals,
          auxiliaries=auxiliaries,
          actions=actions,
          reward=reward,
          reference=policy_reference,
          policy=self.policy,
          baseline=(self.baseline if self.separate_baseline else None),
      )
  
      # Objective loss
      loss = tf.math.reduce_mean(input_tensor=loss, axis=0)
      dependencies = self.summary(
          label="loss",
          name="losses/policy-objective-loss",
          data=loss,
          step="updates",
      )
      dependencies.extend(
          self.track(
              label="loss", name="policy-objective-loss", data=loss
          )
      )
  
      # Regularization losses
      regularization_loss = self.regularize(
          states=states,
          horizons=horizons,
          internals=policy_internals,
          auxiliaries=auxiliaries,
      )
      dependencies.extend(
          self.summary(
              label="loss",
              name="losses/policy-regularization-loss",
              data=regularization_loss,
              step="updates",
          )
      )
      dependencies.extend(
          self.track(
              label="loss",
              name="policy-regularization-loss",
              data=regularization_loss,
          )
      )
      loss += regularization_loss
  
      # Baseline loss
      if (
          self.baseline_loss_weight is not None
          and not self.baseline_loss_weight.is_constant(value=0.0)
      ):
          if self.separate_baseline:
              baseline_internals = internals["baseline"]
          else:
              baseline_internals = policy_internals
          if self.baseline_objective is not None:
              baseline_reference = reference["baseline"]
          else:
              baseline_reference = policy_reference
  
          zero = tf_util.constant(value=0.0, dtype="float")
          baseline_loss_weight = self.baseline_loss_weight.value()
  
          def no_baseline_loss():
              return zero
  
          def apply_baseline_loss():
              baseline_loss = self.baseline_loss(
                  states=states,
                  horizons=horizons,
                  internals=baseline_internals,
                  auxiliaries=auxiliaries,
                  actions=actions,
                  reward=reward,
                  reference=baseline_reference,
              )
              return baseline_loss_weight * baseline_loss
  
          loss += tf.cond(
              pred=tf.math.equal(x=baseline_loss_weight, y=zero),
              true_fn=no_baseline_loss,
              false_fn=apply_baseline_loss,
          )
  
      dependencies.extend(
          self.summary(
              label="loss",
              name="losses/policy-loss",
              data=loss,
              step="updates",
          )
      )
      dependencies.extend(
          self.track(label="loss", name="policy-loss", data=loss)
      )
  
      with tf.control_dependencies(control_inputs=dependencies):
          return tf_util.identity(input=loss)
  
imports: import logging
  import tensorflow
  from tensorforce import TensorforceError
  from tensorforce.core import ModuleDict, memory_modules, optimizer_modules, parameter_modules, SignatureDict, TensorDict, TensorSpec, TensorsSpec, tf_function, tf_util, VariableDict
  from tensorforce.core.models import Model
  from tensorforce.core.networks import Preprocessor
  from tensorforce.core.objectives import objective_modules
  from tensorforce.core.policies import policy_modules, StochasticPolicy
label_desc: Use image node_id 20 for calling the TensorforceModel obj's underlying member method code with example usage: obj.loss() and returns: tf_util, zero, unknown