code: def get_train_weights(self) -> torch.Tensor:
      ids = self.corpus.population.data_split().train
      population = self.corpus.population.population()
      targets = population.loc[ids]["TARGET"].values
  
      class_weights = 1.0 / np.array(
          [len(np.where(targets == t)[0]) for t in np.unique(targets)]
      )
      class_weights = [i / sum(class_weights) for i in class_weights]
      return torch.tensor([class_weights[t] for t in targets]).reshape(
          -1
      )
  
imports: import enum
  import logging
  import pickle
  from dataclasses import dataclass, replace
  from pathlib import Path
  from typing import Any, Dict, List, Optional
  from typing_extensions import dataclass_transform
  import dask
  import dask.dataframe
  import pandas
  import numpy
  import pytorch_lightning
  import torch
  from pandas.tseries.offsets import MonthEnd
  from torch.utils.data import DataLoader, Dataset, WeightedRandomSampler
  from ..tasks.base import Task, collate_encoded_documents
  from .sampler import FixedSampler
  from .dataset import DocumentDataset, ShardedDocumentDataset
  from .decorators import save_parquet, save_pickle
  from .ops import concat_columns_dask, concat_sorted
  from .populations.base import Population
  from .serialize import DATA_ROOT, ValidationError, _jsonify
  from .sources.base import Field, TokenSource
  from .vocabulary import Vocabulary
label_desc: Use image node_id 1 for calling the CLSDataModule obj's underlying member method code with example usage: obj.get_train_weights() and returns: torch