class_docstr: Object that perform the training and active learning iteration.
  
  Args:
      dataset (ActiveLearningDataset): Dataset with some sample already labelled.
      heuristic (Heuristic): Heuristic from baal.active.heuristics.
      query_size (int): Number of sample to label per step.
      max_sample (int): Limit the number of sample used (-1 is no limit).
      **kwargs: Parameters forwarded to `get_probabilities`
          and to pytorch_ligthning Trainer.__init__
docstr: Perform an active learning step.
  
  model: Model to be used in prediction. If None, will get the Trainer's model.
  dataloader (Optional[DataLoader]): If provided, will predict on this dataloader.
                                          Otherwise, uses model.pool_dataloader().
  
  Notes:
      This will get the pool from the model pool_dataloader and if max_sample is set, it will
      **require** the data_loader sampler to select `max_pool` samples.
  
  Returns:
      boolean, Flag indicating if we continue training.
docstr_tok: ["Perform","an","active","learning","step",".","model",":","Model","to","be","used","in","prediction",".","If","None",",","will","get","the","Trainer","'s","model",".","dataloader","(","Optional","[","DataLoader","]",")",":","If","provided",",","will","predict","on","this","dataloader",".","Otherwise",",","uses","model.pool_dataloader","(",")",".","Notes",":","This","will","get","the","pool","from","the","model","pool_dataloader","and","if","max_sample","is","set",",","it","will","*","*","require","*","*","the","data_loader","sampler","to","select","`","max_pool","`","samples",".","Returns",":","boolean",",","Flag","indicating","if","we","continue","training","."]
code: def step(
      self, model=None, datamodule: Optional[BaaLDataModule] = None
  ) -> bool:
      """
      Perform an active learning step.
  
      model: Model to be used in prediction. If None, will get the Trainer's model.
      dataloader (Optional[DataLoader]): If provided, will predict on this dataloader.
                                              Otherwise, uses model.pool_dataloader().
  
      Notes:
          This will get the pool from the model pool_dataloader and if max_sample is set, it will
          **require** the data_loader sampler to select `max_pool` samples.
  
      Returns:
          boolean, Flag indicating if we continue training.
  
      """
      # High to low
      if datamodule is None:
          pool_dataloader = self.lightning_module.pool_dataloader()  # type: ignore
      else:
          pool_dataloader = datamodule.pool_dataloader()
      model = model if model is not None else self.lightning_module
  
      if isinstance(
          pool_dataloader.sampler,
          torch.utils.data.sampler.RandomSampler,
      ):
          log.warning(
              "Your pool_dataloader has `shuffle=True`,"
              " it is best practice to turn this off."
          )
  
      if len(pool_dataloader) > 0:
          # TODO Add support for max_samples in pool_dataloader
          probs = self.predict_on_dataset_generator(
              model=model, dataloader=pool_dataloader, **self.kwargs
          )
          if probs is not None and (
              isinstance(probs, types.GeneratorType) or len(probs) > 0
          ):
              to_label = self.heuristic(probs)
              if len(to_label) > 0:
                  self.dataset.label(to_label[: self.query_size])
                  return True
      return False
  
imports: import sys
  import types
  import warnings
  from collections.abc import Sequence
  from typing import Dict, Any, Optional
  import numpy
  import structlog
  import torch
  from pytorch_lightning import Trainer, Callback, LightningDataModule, LightningModule
  from pytorch_lightning.accelerators import CUDAAccelerator
  from torch.utils.data import DataLoader
  from tqdm import tqdm
  from baal.active import ActiveLearningDataset
  from baal.active.heuristics import heuristics
  from baal.modelwrapper import mc_inference
  from baal.utils.cuda_utils import to_cuda
  from baal.utils.iterutils import map_on_tensor
label_desc: Use image node_id 4 for calling the BaalTrainer obj's underlying member method code with example usage: obj.step(model, datamodule) and returns: False, True