class_docstr: Toxic comment classification for the Jigsaw challenges.
  Args:
      config ([dict]): takes in args from a predefined config
                            file containing hyperparameters.
class_docstr_tok: ["Toxic","comment","classification","for","the","Jigsaw","challenges",".","Args",":","config","(","[","dict","]",")",":","takes","in","args","from","a","predefined","config","file","containing","hyperparameters","."]
docstr: Custom binary_cross_entropy function.
  
  Args:
      output ([torch.tensor]): model predictions
      meta ([dict]): meta dict of tensors including targets and weights
  
  Returns:
      [torch.tensor]: model loss
docstr_tok: ["Custom","binary_cross_entropy","function",".","Args",":","output","(","[","torch.tensor","]",")",":","model","predictions","meta","(","[","dict","]",")",":","meta","dict","of","tensors","including","targets","and","weights","Returns",":","[","torch.tensor","]",":","model","loss"]
code: def binary_cross_entropy(self, input, meta):
      """Custom binary_cross_entropy function.
  
      Args:
          output ([torch.tensor]): model predictions
          meta ([dict]): meta dict of tensors including targets and weights
  
      Returns:
          [torch.tensor]: model loss
      """
  
      if "weight" in meta:
          target = meta["target"].to(input.device).reshape(input.shape)
          weight = meta["weight"].to(input.device).reshape(input.shape)
          return F.binary_cross_entropy_with_logits(
              input, target, weight=weight
          )
      elif "multi_target" in meta:
          target = meta["multi_target"].to(input.device)
          loss_fn = F.binary_cross_entropy_with_logits
          mask = target != -1
          loss = loss_fn(input, target.float(), reduction="none")
  
          if "class_weights" in meta:
              weights = meta["class_weights"][0].to(input.device)
          elif "weights1" in meta:
              weights = meta["weights1"].to(input.device)
          else:
              weights = torch.tensor(1 / self.num_main_classes).to(
                  input.device
              )
              loss = loss[:, : self.num_main_classes]
              mask = mask[:, : self.num_main_classes]
  
          weighted_loss = loss * weights
          nz = torch.sum(mask, 0) != 0
          masked_tensor = weighted_loss * mask
          masked_loss = torch.sum(masked_tensor[:, nz], 0) / torch.sum(
              mask[:, nz], 0
          )
          loss = torch.sum(masked_loss)
          return loss
      else:
          target = meta["target"].to(input.device)
          return F.binary_cross_entropy_with_logits(
              input, target.float()
          )
  
imports: import argparse
  import json
  import os
  import pytorch_lightning
  import src.data_loaders
  import torch
  from pytorch_lightning.callbacks import ModelCheckpoint
  from src.utils import get_model_and_tokenizer
  from torch.nn import functional
  from torch.utils.data import DataLoader
label_desc: Use image node_id 7 for calling the ToxicClassifier obj's underlying member method code with example usage: obj.binary_cross_entropy(input, meta) and returns: F, loss, F