class_docstr: A neural-network based bandit agent for multi-objective optimization.
  
  This agent receives multiple neural networks. Each network will be trained by
  the agent to predict a specific objective. The agent also receives a
  Scalarizer, which transforms multiple predicted objectives to a single reward.
  The action is chosen greedily by the policy with respect to the scalarized
  predicted reward.
docstr: Computes loss for training the objective networks.
  
  Args:
    experience: A batch of experience data in the form of a `Trajectory` or
      `Transition`.
    weights: Optional scalar or elementwise (per-batch-entry) importance
      weights.  The output batch loss will be scaled by these weights, and the
      final scalar loss is the mean of these values.
    training: Whether the loss is being used for training.
  
  Returns:
    loss: A `LossInfo` containing the loss for the training step.
  Raises:
    ValueError:
      - If the number of actions is greater than 1.
      - If `objectives` is not rank-2.
      - If the number of columns in `objectives` does not equal
        `self._num_objectives`.
docstr_tok: ["Computes","loss","for","training","the","objective","networks",".","Args",":","experience",":","A","batch","of","experience","data","in","the","form","of","a","`","Trajectory","`","or","`","Transition","`",".","weights",":","Optional","scalar","or","elementwise","(","per-batch-entry",")","importance","weights",".","The","output","batch","loss","will","be","scaled","by","these","weights",",","and","the","final","scalar","loss","is","the","mean","of","these","values",".","training",":","Whether","the","loss","is","being","used","for","training",".","Returns",":","loss",":","A","`","LossInfo","`","containing","the","loss","for","the","training","step",".","Raises",":","ValueError",":","-","If","the","number","of","actions","is","greater","than","1",".","-","If","`","objectives","`","is","not","rank-2",".","-","If","the","number","of","columns","in","`","objectives","`","does","not","equal","`","self._num_objectives","`","."]
code: def _loss(
      self,
      experience: types.NestedTensor,
      weights: types.Tensor = None,
      training: bool = False,
  ) -> tf_agent.LossInfo:
      """Computes loss for training the objective networks.
  
      Args:
        experience: A batch of experience data in the form of a `Trajectory` or
          `Transition`.
        weights: Optional scalar or elementwise (per-batch-entry) importance
          weights.  The output batch loss will be scaled by these weights, and the
          final scalar loss is the mean of these values.
        training: Whether the loss is being used for training.
  
      Returns:
        loss: A `LossInfo` containing the loss for the training step.
      Raises:
        ValueError:
          - If the number of actions is greater than 1.
          - If `objectives` is not rank-2.
          - If the number of columns in `objectives` does not equal
            `self._num_objectives`.
      """
      (
          observations,
          actions,
          objective_values,
      ) = bandit_utils.process_experience_for_neural_agents(
          experience,
          self._accepts_per_arm_features,
          self.training_data_spec,
      )
      if self._observation_and_action_constraint_splitter is not None:
          (
              observations,
              _,
          ) = self._observation_and_action_constraint_splitter(
              observations
          )
      if objective_values.shape.rank != 2:
          raise ValueError(
              "The objectives tensor should be rank-2 [batch_size, num_objectives],"
              " but found to be rank-{}".format(
                  objective_values.shape.rank
              )
          )
      if objective_values.shape[1] != self._num_objectives:
          raise ValueError(
              "The number of objectives in the objective_values tensor: {} "
              "is different from the number of objective networks: {}.".format(
                  objective_values.shape[1], self._num_objectives
              )
          )
  
      objective_losses = []
      for idx in range(self._num_objectives):
          single_objective_values = objective_values[:, idx]
          objective_losses.append(
              self._single_objective_loss(
                  idx,
                  observations,
                  actions,
                  single_objective_values,
                  weights,
                  training,
              )
          )
  
      self.compute_summaries(objective_losses)
      total_loss = tf.reduce_sum(objective_losses)
      return tf_agent.LossInfo(total_loss, extra=())
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Callable, Optional, Sequence, Text, Tuple
  from absl import logging
  import gin
  import tensorflow
  from tf_agents.agents import data_converter
  from tf_agents.agents import tf_agent
  from tf_agents.bandits.agents import utils
  from tf_agents.bandits.multi_objective import multi_objective_scalarizer
  from tf_agents.bandits.networks import heteroscedastic_q_network
  from tf_agents.bandits.policies import greedy_multi_objective_neural_policy
  from tf_agents.bandits.specs import utils
  from tf_agents.networks.network import Network
  from tf_agents.policies import utils
  from tf_agents.trajectories import time_step
  from tf_agents.typing import types
  from tf_agents.utils import common
  from tf_agents.utils import eager_utils
label_desc: Use image node_id 6 for calling the GreedyMultiObjectiveNeuralAgent obj's underlying member method code with example usage: obj._loss(experience, weights, training) and returns: tf_agent