class_docstr: Base class for all output layers in PyText. The responsibilities of this layer are
  
      1. Implement how loss is computed from logits and targets.
      2. Implement how to get predictions from logits.
      3. Implement the Caffe2 operator for performing the above tasks. This is
          used when PyText exports PyTorch model to Caffe2.
  
  Args:
      loss_fn (type): The loss function object to use for computing loss.
          Defaults to None.
  
  Attributes:
      loss_fn: The loss function object to use for computing loss.
docstr: Compute and return the loss given logits and targets.
  
  Args:
      logit (torch.Tensor): Logits returned :class:`~pytext.models.Model`.
      target (torch.Tensor): True label/target to compute loss against.
      context (Optional[Dict[str, Any]]): Context is a dictionary of items
          that's passed as additional metadata by the
          :class:`~pytext.data.DataHandler`. Defaults to None.
      reduce (bool): Whether to reduce loss over the batch. Defaults to True.
  
  Returns:
      torch.Tensor: Model loss.
code: def get_loss(
      self,
      logit: torch.Tensor,
      target: torch.Tensor,
      context: Optional[Dict[str, Any]] = None,
      reduce: bool = True,
  ) -> torch.Tensor:
      """Compute and return the loss given logits and targets.
  
      Args:
          logit (torch.Tensor): Logits returned :class:`~pytext.models.Model`.
          target (torch.Tensor): True label/target to compute loss against.
          context (Optional[Dict[str, Any]]): Context is a dictionary of items
              that's passed as additional metadata by the
              :class:`~pytext.data.DataHandler`. Defaults to None.
          reduce (bool): Whether to reduce loss over the batch. Defaults to True.
  
      Returns:
          torch.Tensor: Model loss.
  
      """
      return (
          self.loss_fn(logit, target, reduce) if self.loss_fn else None
      )
  
file_path: pytext/pytext/models/output_layers/output_layer_base.py
imports: from typing import Any, Dict, List, Optional, Tuple
  import torch
  from caffe2.python import core
  from pytext.loss import Loss
  from pytext.models.module import Module
  from pytext.utils.usage import log_class_usage
label_desc: Use image node_id 2 for calling the OutputLayerBase obj's underlying member method code with example usage: obj.get_loss(logit, target, context, reduce) and returns: unknown