class_docstr: ## Configurations
  
  We extend [GPT configurations](../gpt/index.html) and change the attention mechanism.
class_docstr_tok: ["#","#","Configurations","We","extend","[","GPT","configurations","]","(","..","\/gpt\/index.html",")","and","change","the","attention","mechanism","."]
docstr: Log losses at the initial and final tokens
docstr_tok: ["Log","losses","at","the","initial","and","final","tokens"]
code: def other_metrics(self, output: torch.Tensor, target: torch.Tensor):
      """
      Log losses at the initial and final tokens
      """
      # If there are more tokens that the training sequence length (during validation),
      if self.seq_len < output.shape[0]:
          # Log the loss at training sequence length
          tracker.add(
              f"loss.{self.seq_len - 1}.",
              self.loss_func(
                  output[self.seq_len - 1], target[self.seq_len - 1]
              ),
          )
          # Log the loss at the first token
          tracker.add(f"loss.0.", self.loss_func(output[0], target[0]))
      # Log the loss at the final token
      tracker.add(
          f"loss.{int(output.shape[0]) - 1}.",
          self.loss_func(output[-1], target[-1]),
      )
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/transformers/alibi/experiment.py
imports: import torch
  from torch.utils.data import DataLoader
  from labml import experiment, tracker
  from labml.configs import option, calculate
  from labml_helpers.datasets.text import SequentialUnBatchedDataset
  from labml_nn.transformers.alibi import AlibiMultiHeadAttention
  from labml_nn.experiments.nlp_autoregression import transpose_batch
  from labml_nn.transformers import TransformerConfigs
  from labml_nn.transformers.gpt import Configs
label_desc: Use image node_id 1 for calling the Configs obj's underlying member method code with example usage: obj.other_metrics(output, target) without return types