class_docstr: Dataloader for the Jigsaw Unintended Bias in Toxicity Classification.
  Source: https://www.kaggle.com/c/jigsaw-unintended-bias-in-toxicity-classification/
class_docstr_tok: ["Dataloader","for","the","Jigsaw","Unintended","Bias","in","Toxicity","Classification",".","Source",":","https",":","\/\/www.kaggle.com\/c\/jigsaw-unintended-bias-in-toxicity-classification\/"]
docstr: Inspired from 2nd best solution.
  Source: https://www.kaggle.com/c/jigsaw-unintended-bias-in-toxicity-classification/discussion/100661
docstr_tok: ["Inspired","from","2nd","best","solution",".","Source",":","https",":","\/\/www.kaggle.com\/c\/jigsaw-unintended-bias-in-toxicity-classification\/discussion\/100661"]
code: def compute_weigths(self, train_df):
      """Inspired from 2nd best solution.
      Source: https://www.kaggle.com/c/jigsaw-unintended-bias-in-toxicity-classification/discussion/100661
      """
      subgroup_bool = (
          train_df[self.identity_classes].fillna(0) >= 0.5
      ).sum(axis=1) > 0
      positive_bool = train_df["toxicity"] >= 0.5
      weights = np.ones(len(train_df)) * 0.25
  
      # Background Positive and Subgroup Negative
      # i.e. weigh higher toxic comments that don't mention identity and non toxic ones that mention it
      weights[
          ((~subgroup_bool) & (positive_bool))
          | ((subgroup_bool) & (~positive_bool))
      ] += 0.25
      weights[(subgroup_bool)] += 0.25
      return weights
  
imports: import datasets
  import numpy
  import pandas
  import torch
  from torch.utils.data.dataset import Dataset
  from tqdm import tqdm
label_desc: Use image node_id 3 for calling the JigsawDataBias obj's underlying member method code with example usage: obj.compute_weigths(train_df) and returns: weights