code: def automatic_add_label_in_dataloader(
      model, dataloader, input_sample=None
  ):
      if _check_whether_add_label(model, dataloader, input_sample):
          # need to add label automaticly
          # generate a warning for user first
          warnings.warn(
              "After checking, it is found that your data does not contain a label item. "
              "In order to make quantification work normally, we will automatically "
              "generate a dummy label."
          )
  
          # define a decorator to add label
          def label_collate_fn_wrapper(func):
              def collate_fn(batch):
                  res = func(batch)
                  # add dummy label
                  return res, torch.ones(1).long()
  
              return collate_fn
  
          # construct a new dataloader
          new_dataloader = deepcopy(dataloader)
          new_dataloader.collate_fn = label_collate_fn_wrapper(
              new_dataloader.collate_fn
          )
          return new_dataloader
      return dataloader
  
file_path: BigDL/python/nano/src/bigdl/nano/utils/pytorch/dataloader.py
imports: from typing import Sequence
  from copy import deepcopy
  import torch
  import warnings
  from bigdl.nano.utils.pytorch import get_conditional_args
label_desc: Use image node_id 2 for calling a global function with example usage: automatic_add_label_in_dataloader(model, dataloader, input_sample) and returns: dataloader, new_dataloader, collate_fn, res,  torch