code: def __init__(
      self,
      total_samples: int,
      consumed_samples: int,
      micro_batch_size: int,
      data_parallel_rank: int,
      data_parallel_size: int,
      drop_last: bool = True,
      global_batch_size: Optional[int] = None,
      rampup_batch_size: Optional[list] = None,
      pad_samples_to_global_batch_size: Optional[bool] = False,
  ) -> None:
      # Sanity checks.
      if total_samples <= 0:
          raise RuntimeError(
              "no sample to consume: {}".format(total_samples)
          )
      if micro_batch_size <= 0:
          raise RuntimeError(
              f"micro_batch_size size must be greater than 0, but {micro_batch_size}"
          )
      if data_parallel_size <= 0:
          raise RuntimeError(
              f"data parallel size must be greater than 0, but {data_parallel_size}"
          )
      if data_parallel_rank >= data_parallel_size:
          raise RuntimeError(
              "data_parallel_rank should be smaller than data size, but {} >= {}".format(
                  data_parallel_rank, data_parallel_size
              )
          )
      if global_batch_size is not None and rampup_batch_size is None:
          if (
              global_batch_size
              % (micro_batch_size * data_parallel_size)
              != 0
          ):
              raise RuntimeError(
                  f"`global_batch_size` ({global_batch_size}) is not divisible by "
                  f"`micro_batch_size ({micro_batch_size}) x data_parallel_size "
                  f"({data_parallel_size})`"
              )
      if pad_samples_to_global_batch_size and global_batch_size is None:
          raise RuntimeError(
              f"`pad_samples_to_global_batch_size` can be `True` only when "
              f"`global_batch_size` is set to an integer value"
          )
  
      # Keep a copy of input params for later use.
      self.total_samples = total_samples
      self.consumed_samples = consumed_samples
      self.micro_batch_size = micro_batch_size
      self.data_parallel_rank = data_parallel_rank
      self.data_parallel_size = data_parallel_size
      self.micro_batch_times_data_parallel_size = (
          self.micro_batch_size * data_parallel_size
      )
      self.drop_last = drop_last
      self.global_batch_size = global_batch_size
      self.pad_samples_to_global_batch_size = (
          pad_samples_to_global_batch_size
      )
  
      logging.info(
          f"Instantiating MegatronPretrainingSampler with total_samples: {total_samples} and consumed_samples: {consumed_samples}"
      )
  
file_path: NeMo/nemo/collections/nlp/data/language_modeling/megatron/data_samplers.py
imports: import abc
  from itertools import chain
  from typing import Optional
  import torch
  from nemo.utils import logging
label_desc: Use image node_id 1 to create a new BaseMegatronSampler object  with example: obj = BaseMegatronSampler(total_samples, consumed_samples, micro_batch_size, data_parallel_rank, data_parallel_size, drop_last, global_batch_size, rampup_batch_size, pad_samples_to_global_batch_size)