Multi-Label Joint Intent Slot Classification
State: closed | Pull request: yes

# What does this PR do ?

Multi-Label Intent Model for Joint Intent Slot Classification Task. 

**Collection**: [Note which collection this PR will affect]

This PR will involves changes in collections/nlp within NeMo.

# Changelog 
- New loss function added to collections/common/losses (BCEWithLogitsLoss)
- Multi-Label Classification Report added to collections/nlp/metrics/classification_report
- Multi-Label Classification Model, Descriptor, Dataset files added in similar folders to intent_slot_classification
- Data Conversion and Augmentation scripts added to example/nlp/multi_label_intent_slot_classification Multi-Label Training Tutorial added to https://github.com/NVIDIA/NeMo/blob/main/tutorials/nlp/Joint_Intent_and_Slot_Classification.ipynb
- Added Weight Calculation Function for BCEWithLogitsLoss (lines 512-537) and Multi Label Stats function (lines 201-242) in nlp/data/data_utils/data_preprocessing.py 



# Usage

Refer to https://github.com/NVIDIA/NeMo/blob/main/tutorials/nlp/Joint_Intent_and_Slot_Classification.ipynb for training. To run the tutorial you will need to change github string link name from NVIDIA to chenrichard10 if the PR has not been approved. 

A simple script that can be used to train the model locally can be with  
 
```python
from nemo.collections import nlp as nemo_nlp
from nemo.utils.exp_manager import exp_manager
from nemo.utils import logging
from nemo.collections.nlp.parts.utils_funcs import tensor2list

import os
import time

import torch
import pytorch_lightning as pl

from omegaconf import OmegaConf

HOME_DIR=""

# directory with data converted to nemo format
data_dir = os.path.join(HOME_DIR, "new_multiatis")

run_name = "test"
config_file = ""
config = OmegaConf.load(config_file)
config.model.data_dir = data_dir
config.model.validation_ds.prefix = "dev"
config.model.test_ds.prefix = "test"
config.model.class_balancing = "weighted_loss"
config.model.head.num_output_layers = 2
config.trainer.max_epochs = 40


# checks if we have GPU available and uses it
cuda = 1 if torch.cuda.is_available() else 0
config.trainer.gpus = cuda

# config.trainer.precision = 16 if torch.cuda.is_available() else 32
config.trainer.precision = 32

# for mixed precision training, uncomment the line below (precision should be set to 16 and amp_level to O1):
# config.trainer.amp_level = 'O1'

# remove distributed training flags
config.trainer.accelerator = None

# early_stop_callback = EarlyStopping(monitor='intent_f1', min_delta=1e-1, patience=10, verbose=True, mode='max')

trainer = pl.Trainer(**config.trainer)
config.exp_manager.exp_dir = os.path.join(HOME_DIR, "output/" + run_name)
config.exp_manager.create_checkpoint_callback = True
config.exp_manager.version = time.strftime('%Y-%m-%d_%H-%M-%S')

exp_dir = exp_manager(trainer, config.get("exp_manager", None))
model = nemo_nlp.models.MultiLabelIntentSlotClassificationModel(config.model, trainer=trainer)
trainer.fit(model)
```


**Pre checks**:
- [x] Make sure you read and followed [Contributor guidelines](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md)
- [x] Did you write any new necessary tests?
- [x] Did you add or update any necessary documentation?
- [x] Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
  - [ ] Reviewer: Does the PR have correct import guards for all optional libraries?
  
**PR Type**:
- [x] New Feature
- [ ] Bugfix
- [ ] Documentation

If you haven't finished some of the above items you can still open "Draft" PR.


## Who can review?

Anyone in the community is free to review the PR once the checks have passed. 
[Contributor guidelines](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md) contains specific people who can review PRs to various areas.

# Additional Information
Available model has yet to be trained and uploaded on NGC. Section will be updated once a model has been trained.