docstr: Args:
      x: A Variable containing a FloatTensor of size
          (batch, max_len) which contains the
          unnormalized probability for each class.
      target: A Variable containing a LongTensor of size
          (batch, max_len) which contains the index of the true
          class for each corresponding step.
      length: A Variable containing a LongTensor of size (batch,)
          which contains the length of each data in a batch.
  Shapes:
      x: B x T
      target: B x T
      length: B
  Returns:
      loss: An average loss value in range [0, 1] masked by the length.
docstr_tok: ["Args",":","x",":","A","Variable","containing","a","FloatTensor","of","size","(","batch",",","max_len",")","which","contains","the","unnormalized","probability","for","each","class",".","target",":","A","Variable","containing","a","LongTensor","of","size","(","batch",",","max_len",")","which","contains","the","index","of","the","true","class","for","each","corresponding","step",".","length",":","A","Variable","containing","a","LongTensor","of","size","(","batch",",",")","which","contains","the","length","of","each","data","in","a","batch",".","Shapes",":","x",":","B","x","T","target",":","B","x","T","length",":","B","Returns",":","loss",":","An","average","loss","value","in","range","[","0",",","1","]","masked","by","the","length","."]
code: def forward(self, x, target, length):
      """
      Args:
          x: A Variable containing a FloatTensor of size
              (batch, max_len) which contains the
              unnormalized probability for each class.
          target: A Variable containing a LongTensor of size
              (batch, max_len) which contains the index of the true
              class for each corresponding step.
          length: A Variable containing a LongTensor of size (batch,)
              which contains the length of each data in a batch.
      Shapes:
          x: B x T
          target: B x T
          length: B
      Returns:
          loss: An average loss value in range [0, 1] masked by the length.
      """
      # mask: (batch, max_len, 1)
      target.requires_grad = False
      if length is not None:
          mask = sequence_mask(
              sequence_length=length, max_len=target.size(1)
          ).float()
          x = x * mask
          target = target * mask
          num_items = mask.sum()
      else:
          num_items = torch.numel(x)
      loss = functional.binary_cross_entropy_with_logits(
          x, target, pos_weight=self.pos_weight, reduction="sum"
      )
      loss = loss / num_items
      return loss
  
imports: import math
  import numpy
  import torch
  from torch import nn
  from inspect import signature
  from torch.nn import functional
  from TTS.tts.utils.generic_utils import sequence_mask
  from TTS.tts.utils.ssim import ssim
label_desc: Use image node_id 2 for calling the BCELossMasked obj's underlying member method code with example usage: obj.forward(x, target, length) and returns: loss