code: def __init__(
      self,
      total_samples: int,
      consumed_samples: int,
      micro_batch_size: int,
      global_batch_size: int,
      data_parallel_rank: int,
      data_parallel_size: int,
      drop_last: bool,
      pad_samples_to_global_batch_size: bool = False,
      seed: int = 0,
  ) -> 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
              )
          )
  
      self.total_samples: int = total_samples
      self.consumed_samples: int = consumed_samples
      self.micro_batch_size: int = micro_batch_size
      self.data_parallel_rank: int = data_parallel_rank
      self.data_parallel_size: int = data_parallel_size
      self.drop_last: bool = drop_last
      self.pad_samples_to_global_batch_size = (
          pad_samples_to_global_batch_size
      )
      self.seed = seed
  
      self.update_global_batch_size(global_batch_size)
      self.last_batch_size = (
          self.total_samples % self._global_batch_size
      )
  
imports: import abc
  import warnings
  from typing import Tuple
  import torch
  from nemo.utils.decorators import experimental
label_desc: Use image node_id 1 to create a new MegatronPretrainingRandomBatchSampler object from inherited base classes: BaseMegatronBatchSampler with example: obj = MegatronPretrainingRandomBatchSampler(total_samples, consumed_samples, micro_batch_size, global_batch_size, data_parallel_rank, data_parallel_size, drop_last, pad_samples_to_global_batch_size, seed)