class_docstr: Neural module which implements loss for SGD model.
class_docstr_tok: ["Neural","module","which","implements","loss","for","SGD","model","."]
docstr: flattens logits and labels according loss mask
  Args:
      logits: logits
      labels: labels
      loss_mask: loss mask
  Returns:
      logits_flatten: flattened logits where loss mask is true
      labels_flatten: flattened labels where loss mask is true
docstr_tok: ["flattens","logits","and","labels","according","loss","mask","Args",":","logits",":","logits","labels",":","labels","loss_mask",":","loss","mask","Returns",":","logits_flatten",":","flattened","logits","where","loss","mask","is","true","labels_flatten",":","flattened","labels","where","loss","mask","is","true"]
code: def _helper(self, logits, labels, loss_mask=None):
      """
      flattens logits and labels according loss mask
      Args:
          logits: logits
          labels: labels
          loss_mask: loss mask
      Returns:
          logits_flatten: flattened logits where loss mask is true
          labels_flatten: flattened labels where loss mask is true
      """
      logits_flatten = torch.flatten(logits, start_dim=0, end_dim=-2)
      labels_flatten = torch.flatten(labels, start_dim=0, end_dim=-1)
  
      if loss_mask is not None:
          if loss_mask.dtype is not torch.bool:
              loss_mask = loss_mask > 0.5
          loss_mask_flatten = torch.flatten(
              loss_mask, start_dim=0, end_dim=-1
          )
          logits_flatten = logits_flatten[loss_mask_flatten]
          labels_flatten = labels_flatten[loss_mask_flatten]
  
      return logits_flatten, labels_flatten
  
file_path: NeMo/nemo/collections/nlp/losses/sgd_loss.py
imports: import torch
  from nemo.core.classes import Loss, Typing, typecheck
  from nemo.core.neural_types import ChannelType, LabelsType, LogitsType, LossType, NeuralType
  from nemo.utils import logging
label_desc: Use image node_id 4 for calling the SGDDialogueStateLoss obj's underlying member method code with example usage: obj._helper(logits, labels, loss_mask) and returns: logits_flatten,  labels_flatten