code: def get_balanced_sampler(y_train):
      assert (
          y_train.ndim == 1
      ), "Utility function only works for binary classification"
      y_train = LabelEncoder().fit_transform(y_train)
      class_sample_counts = np.bincount(y_train)
      # compute weight for all the samples in the dataset
      # samples_weights contain the probability for each example in dataset to be sampled
      class_weights = 1.0 / torch.Tensor(class_sample_counts)
      train_samples_weight = [
          class_weights[class_id] for class_id in y_train
      ]
      # now lets initialize samplers
      train_sampler = torch.utils.data.sampler.WeightedRandomSampler(
          train_samples_weight, len(y_train)
      )
      return train_sampler
  
file_path: pytorch_tabular/src/pytorch_tabular/utils/data_utils.py
imports: import gzip
  import os
  import random
  import shutil
  import numpy
  import pandas
  import requests
  import torch
  from pandas import DataFrame, Series
  from sklearn.cluster import KMeans
  from sklearn.datasets import make_classification, make_regression
  from sklearn.preprocessing import LabelEncoder
  from .logger import get_logger
label_desc: Use image node_id 3 for calling a global function with example usage: get_balanced_sampler(y_train) and returns: train_sampler