class_docstr: Transformers base model (for working with pytorch-transformers models)
class_docstr_tok: ["Transformers","base","model","(","for","working","with","pytorch-transformers","models",")"]
code: def _evaluate(self, data_set: DataLoader):
      logger.info("***** Running inference *****")
      logger.info(" Batch size: {}".format(data_set.batch_size))
      eval_loss = 0.0
      nb_eval_steps = 0
      preds = None
      out_label_ids = None
      for batch in tqdm(data_set, desc="Inference iteration"):
          self.model.eval()
          batch = tuple(t.to(self.device) for t in batch)
  
          with torch.no_grad():
              inputs = self._batch_mapper(batch)
              outputs = self.model(**inputs)
              if "labels" in inputs:
                  tmp_eval_loss, logits = outputs[:2]
                  eval_loss += tmp_eval_loss.mean().item()
              else:
                  logits = outputs[0]
          nb_eval_steps += 1
          model_output = logits.detach().cpu()
          model_out_label_ids = (
              inputs["labels"].detach().cpu()
              if "labels" in inputs
              else None
          )
          if preds is None:
              preds = model_output
              out_label_ids = model_out_label_ids
          else:
              preds = torch.cat((preds, model_output), dim=0)
              out_label_ids = (
                  torch.cat((out_label_ids, model_out_label_ids), dim=0)
                  if out_label_ids is not None
                  else None
              )
      if out_label_ids is None:
          return preds
      return preds, out_label_ids
  
imports: import io
  import logging
  import os
  from typing import List, Union
  import torch
  from torch.utils.data import DataLoader
  from tqdm import tqdm, trange
  from transformers import AdamW, BertConfig, BertTokenizer, RobertaConfig, RobertaTokenizer, XLMConfig, XLMTokenizer, XLNetConfig, XLNetTokenizer, get_linear_schedule_with_warmup
  from nlp_architect.models import TrainableModel
  from nlp_architect.models.transformers.quantized_bert import QuantizedBertConfig
label_desc: Use image node_id 16 for calling the TransformerBase obj's underlying member method code with example usage: obj._evaluate(data_set) and returns: preds,  out_label_ids, preds