class_docstr: The purpose of this wrapper is to provide extra capabilities for HuggingFace Trainer, so that
  it can output several forward pass for samples in prediction time and hence be able to work with
  baal. For a more detailed description of the arguments refer to (
  https://huggingface.co/transformers/v3.0.2/main_classes/trainer.html)
  
  Args:
      model (transformers.PreTrainedModel): The model to train, evaluate or use for predictions.
      replicate_in_memory: If True, will perform MC-Dropout in a single forward pass.
          It is faster, but more memory expensive. Default: True.
      data_collator (Optional(Callable)): The function to use to from a batch.
      train_dataset (Optional(torch.utils.data.Dataset)): The dataset to use for training.
      eval_dataset (Optional(torch.utils.data.Dataset)): The dataset to use for evaluation.
      tokenizer (Optional(transformers.PreTrainedTokenizer)): a tokenizer provided by huggingface.
      model_init (Optional(Dict)): Model initial weights for fine tuning.
      compute_metrics (Optional(Callable[[EvalPrediction], Dict])): The function that will be
          used to compute metrics at evaluation.
      callbacks (Optional(List[transformers.TrainerCallback])): A list of callbacks to customize
          the training loop.
      optimizers (Optional(Tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR])):
          A tuple containing the optimizer and the scheduler to use.
class_docstr_tok: ["The","purpose","of","this","wrapper","is","to","provide","extra","capabilities","for","HuggingFace","Trainer",",","so","that","it","can","output","several","forward","pass","for","samples","in","prediction","time","and","hence","be","able","to","work","with","baal",".","For","a","more","detailed","description","of","the","arguments","refer","to","(","https",":","\/\/huggingface.co\/transformers\/v3.0.2\/main_classes\/trainer.html",")","Args",":","model","(","transformers.PreTrainedModel",")",":","The","model","to","train",",","evaluate","or","use","for","predictions",".","replicate_in_memory",":","If","True",",","will","perform","MC-Dropout","in","a","single","forward","pass",".","It","is","faster",",","but","more","memory","expensive",".","Default",":","True",".","data_collator","(","Optional","(","Callable",")",")",":","The","function","to","use","to","from","a","batch",".","train_dataset","(","Optional","(","torch.utils.data.Dataset",")",")",":","The","dataset","to","use","for","training",".","eval_dataset","(","Optional","(","torch.utils.data.Dataset",")",")",":","The","dataset","to","use","for","evaluation",".","tokenizer","(","Optional","(","transformers.PreTrainedTokenizer",")",")",":","a","tokenizer","provided","by","huggingface",".","model_init","(","Optional","(","Dict",")",")",":","Model","initial","weights","for","fine","tuning",".","compute_metrics","(","Optional","(","Callable","[","[","EvalPrediction","]",",","Dict","]",")",")",":","The","function","that","will","be","used","to","compute","metrics","at","evaluation",".","callbacks","(","Optional","(","List","[","transformers.TrainerCallback","]",")",")",":","A","list","of","callbacks","to","customize","the","training","loop",".","optimizers","(","Optional","(","Tuple","[","torch.optim.Optimizer",",","torch.optim.lr_scheduler.LambdaLR","]",")",")",":","A","tuple","containing","the","optimizer","and","the","scheduler","to","use","."]
code: def __init__(
      self,
      model: Union[PreTrainedModel, nn.Module] = None,
      args: TrainingArguments = None,
      replicate_in_memory=True,
      **kwargs,
  ):
      self.replicate_in_memory = replicate_in_memory
      super().__init__(model=model, args=args, **kwargs)
      raise_warnings_cache_replicated(model, replicate_in_memory)
  
file_path: baal/baal/transformers_trainer_wrapper.py
imports: from typing import Optional, List, Sequence, Union
  import numpy
  import structlog
  import torch
  from torch import nn
  from tqdm import tqdm
  from transformers import PreTrainedModel, TrainingArguments
  from baal.utils.warnings import raise_warnings_cache_replicated
  from baal.utils.array_utils import stack_in_memory
  from baal.utils.iterutils import map_on_tensor
label_desc: Use image node_id 1 to create a new BaalTransformersTrainer object from inherited base classes: Trainer with example: obj = BaalTransformersTrainer(model, args, replicate_in_memory)