class_docstr: Left-to-right Transformer language model.
class_docstr_tok: ["Left-to-right","Transformer","language","model","."]
code: def setup_validation_data(
      self, val_data_config: Optional[DictConfig]
  ):
      self._validation_dl = self._setup_dataloader_from_config(
          cfg=val_data_config
      )
  
      # Need to set this because if using an IterableDataset, the length of the dataloader is the total number
      # of samples rather than the number of batches, and this messes up the tqdm progress bar.
      # So we set the number of steps manually (to the correct number) to fix this.
      if (
          "use_tarred_dataset" in val_data_config
          and val_data_config["use_tarred_dataset"]
      ):
          # We also need to check if limit_val_batches is already set.
          # If it's an int, we assume that the user has set it to something sane, i.e. <= # validation batches,
          # and don't change it. Otherwise, adjust batches accordingly if it's a float (including 1.0).
          if self._trainer is not None and isinstance(
              self._trainer.limit_val_batches, float
          ):
              self._trainer.limit_val_batches = int(
                  self._trainer.limit_val_batches
                  * math.ceil(
                      len(self._validation_dl.dataset) / self.world_size
                  )
              )
          elif self._trainer is None:
              logging.warning(
                  "Model Trainer was not set before constructing the dataset, incorrect number of "
                  "validation batches will be used. Please set the trainer and rebuild the dataset."
              )
  
imports: import json
  import math
  from typing import Dict, Optional
  import numpy
  import torch
  import torch.utils.data
  from omegaconf import DictConfig, OmegaConf
  from pytorch_lightning import Trainer
  from nemo.collections.common.losses import SmoothedCrossEntropyLoss
  from nemo.collections.common.metrics import GlobalAverageLossMetric
  from nemo.collections.common.parts import transformer_weights_init
  from nemo.collections.nlp.data import SentenceDataset, TarredSentenceDataset
  from nemo.collections.nlp.metrics import SequencePerplexity
  from nemo.collections.nlp.modules.common import TokenClassifier
  from nemo.collections.nlp.modules.common.lm_utils import get_transformer
  from nemo.collections.nlp.modules.common.tokenizer_utils import get_tokenizer
  from nemo.core.classes.common import typecheck
  from nemo.core.classes.modelPT import ModelPT
  from nemo.utils import logging, model_utils
label_desc: Use image node_id 12 for calling the TransformerLMModel obj's underlying member method code with example usage: obj.setup_validation_data(val_data_config) without return types