class_docstr: Implements
  "Direct Preference Optimization:
  Your Language Model is Secretly a Reward Model"
  from https://arxiv.org/abs/2305.18290
class_docstr_tok: ["Implements","''","Direct","Preference","Optimization",":","Your","Language","Model","is","Secretly","a","Reward","Model","''","from","https",":","\/\/arxiv.org\/abs\/2305.18290"]
code: def get_losses(self, logits):
      # The beta is a temperature parameter for the DPO loss,
      # typically something in the range of 0.1 to 0.5.
      # We ignore the reference model as beta -> 0.
      # The label_smoothing parameter encodes our uncertainty about the labels and
      # calculates a conservative DPO loss.
  
      # For now, set label_smoothing to 0 (original DPO loss).
      # See https://ericmitchell.ai/cdpo.pdf for more details
      label_smoothing = 0
  
      losses = (
          -F.logsigmoid(self.cfg.training.beta * logits)
          * (1 - label_smoothing)
          - F.logsigmoid(-self.cfg.training.beta * logits)
          * label_smoothing
      )
      return losses
  
file_path: h2o-llmstudio/llm_studio/src/losses/text_dpo_modeling_losses.py
imports: import logging
  from typing import Any, KeysView, Tuple
  import torch
  import torch.nn.functional
  from torch import nn
label_desc: Use image node_id 3 for calling the DPOLoss obj's underlying member method code with example usage: obj.get_losses(logits) and returns: losses