class_docstr: Output layer for word tagging models. It supports `CrossEntropyLoss` per word.
  
  Args:
      loss_fn (CrossEntropyLoss): Cross-entropy loss component. Defaults to None.
  
  Attributes:
      loss_fn: Cross-entropy loss component.
class_docstr_tok: ["Output","layer","for","word","tagging","models",".","It","supports","`","CrossEntropyLoss","`","per","word",".","Args",":","loss_fn","(","CrossEntropyLoss",")",":","Cross-entropy","loss","component",".","Defaults","to","None",".","Attributes",":","loss_fn",":","Cross-entropy","loss","component","."]
docstr: Compute word tagging loss by comparing prediction of each word in the
  sentence with its true label/target.
  
  Args:
      logit (torch.Tensor): Logit returned by
          :class:`~pytext.models.word_model.WordTaggingModel`.
      targets (torch.Tensor): True document label/target.
      context (Dict[str, Any]): Context is a dictionary of items
          that's passed as additional metadata. Defaults to None.
      reduce (bool): Whether to reduce loss over the batch. Defaults to True.
  
  Returns:
      torch.Tensor: Word tagging loss for all words in the sentence.
docstr_tok: ["Compute","word","tagging","loss","by","comparing","prediction","of","each","word","in","the","sentence","with","its","true","label\/target",".","Args",":","logit","(","torch.Tensor",")",":","Logit","returned","by",":","class",":","`","~pytext.models.word_model.WordTaggingModel","`",".","targets","(","torch.Tensor",")",":","True","document","label\/target",".","context","(","Dict","[","str",",","Any","]",")",":","Context","is","a","dictionary","of","items","that","'s","passed","as","additional","metadata",".","Defaults","to","None",".","reduce","(","bool",")",":","Whether","to","reduce","loss","over","the","batch",".","Defaults","to","True",".","Returns",":","torch.Tensor",":","Word","tagging","loss","for","all","words","in","the","sentence","."]
code: def get_loss(
      self,
      logit: torch.Tensor,
      target: Union[
          torch.Tensor, Tuple[torch.Tensor, torch.Tensor, torch.Tensor]
      ],
      context: Dict[str, Any],
      reduce: bool = True,
  ) -> torch.Tensor:
      """Compute word tagging loss by comparing prediction of each word in the
      sentence with its true label/target.
  
      Args:
          logit (torch.Tensor): Logit returned by
              :class:`~pytext.models.word_model.WordTaggingModel`.
          targets (torch.Tensor): True document label/target.
          context (Dict[str, Any]): Context is a dictionary of items
              that's passed as additional metadata. Defaults to None.
          reduce (bool): Whether to reduce loss over the batch. Defaults to True.
  
      Returns:
          torch.Tensor: Word tagging loss for all words in the sentence.
  
      """
  
      orig_target = target.clone()
  
      # Structured losses require access to sequences in each batch, so don't
      # flatten logits and targets for these.
      if not isinstance(self.loss_fn, StructuredLoss):
          logit = logit.view(
              -1, logit.size(-1)
          )  # B x T x V -> (B x T) x V
          target = target.view(-1)  # B x T -> (B x T)
  
      if isinstance(target, tuple):
          hard_target, _, soft_target = target
          target = (
              hard_target.view(-1),
              None,
              soft_target.view(-1, soft_target.size(-1)),
          )
          return self.loss_fn(logit, orig_target, reduce)
  
      return self.loss_fn(logit, target, reduce)
  
imports: from typing import Any, Dict, List, Optional, Tuple, Union
  import torch
  import torch.jit
  import torch.nn
  import torch.nn.functional
  from caffe2.python import core
  from pytext.common import Padding
  from pytext.config.component import create_loss
  from pytext.config.serialize import MissingValueError
  from pytext.data.utils import Vocabulary
  from pytext.loss import AUCPRHingeLoss, BinaryCrossEntropyLoss, CrossEntropyLoss, KLDivergenceBCELoss, KLDivergenceCELoss, LabelSmoothedCrossEntropyLoss, StructuredLoss, StructuredMarginLoss
  from pytext.models.crf import CRF
  from pytext.utils.label import get_label_weights
  from pytext.utils.usage import log_class_usage
  from .output_layer_base import OutputLayerBase
  from .utils import OutputLayerUtils
label_desc: Use image node_id 2 for calling the WordTaggingOutputLayer obj's underlying member method code with example usage: obj.get_loss(logit, target, context, reduce) and returns: self, self