docstr: Computes all evaluation losses for the model given targets and predictions.
  
  Args:
      targets: A dictionary of target names to target tensors.
      predictions: A dictionary of output names to output tensors.
  
  Returns:
      A tuple of loss values for eval losses and additional losses.
docstr_tok: ["Computes","all","evaluation","losses","for","the","model","given","targets","and","predictions",".","Args",":","targets",":","A","dictionary","of","target","names","to","target","tensors",".","predictions",":","A","dictionary","of","output","names","to","output","tensors",".","Returns",":","A","tuple","of","loss","values","for","eval","losses","and","additional","losses","."]
code: def eval_loss(self, targets, predictions):
      """Computes all evaluation losses for the model given targets and predictions.
  
      Args:
          targets: A dictionary of target names to target tensors.
          predictions: A dictionary of output names to output tensors.
  
      Returns:
          A tuple of loss values for eval losses and additional losses.
      """
      eval_loss = 0
      for of_name, of_obj in self.output_features.items():
          if isinstance(of_obj, TextOutputFeature):
              # Align the target length with the predictions length to enable text metric evaluation.
              (
                  _targets,
                  _predictions,
              ) = get_realigned_target_and_prediction_tensors_for_inference(
                  targets, predictions, of_name, self.tokenizer
              )
              of_eval_loss = of_obj.eval_loss(
                  _targets[of_name], _predictions[of_name]
              )
          else:
              # HACK(geoffrey): we need a non-empty loss, so we just fill it with zeros
              of_eval_loss = torch.tensor(0.0).to(
                  predictions[of_name][LOGITS].device
              )
  
          eval_loss += of_obj.loss.weight * of_eval_loss
  
      additional_loss = 0
      additional_losses = self.losses()
      if additional_losses:
          additional_loss = torch.sum(
              torch.stack(additional_losses)
          )  # other losses
  
      return eval_loss, additional_loss
  
imports: import contextlib
  import logging
  import os
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from transformers import AutoConfig, GenerationConfig
  from ludwig.accounting.used_tokens import get_used_tokens_for_llm
  from ludwig.constants import IGNORE_INDEX_TOKEN_ID, LOGITS, MODEL_LLM, PREDICTIONS, TEXT, USED_TOKENS
  from ludwig.features.base_feature import ModuleWrapper, OutputFeature
  from ludwig.features.feature_utils import LudwigFeatureDict
  from ludwig.features.text_feature import TextOutputFeature
  from ludwig.globals import MODEL_WEIGHTS_FILE_NAME
  from ludwig.models.base import BaseModel
  from ludwig.modules.training_hooks import NEFTuneHook
  from ludwig.schema.features.base import BaseOutputFeatureConfig, FeatureCollection
  from ludwig.schema.model_types.llm import LLMModelConfig
  from ludwig.utils.augmentation_utils import AugmentationPipelines
  from ludwig.utils.data_utils import clear_data_cache
  from ludwig.utils.llm_quantization_utils import convert_quantized_linear_to_linear
  from ludwig.utils.llm_utils import add_left_padding, generate_merged_ids, get_context_len, get_realigned_target_and_prediction_tensors_for_inference, initialize_adapter, load_pretrained_from_config, pad_target_tensor_for_fine_tuning, remove_left_padding, to_device
  from ludwig.utils.logging_utils import log_once
  from ludwig.utils.output_feature_utils import set_output_feature_tensor
  from ludwig.utils.tokenizers import HFTokenizer
  from ludwig.utils.torch_utils import reg_loss
label_desc: Use image node_id 22 for calling the LLM obj's underlying member method code with example usage: obj.eval_loss(targets, predictions) and returns: eval_loss,  additional_loss