class_docstr: Samples mini-batches randomly but in a grouped manner.
  
  This means that the items from the different groups are always sampled together.
  This is an abstract class. Implement the :py:meth:`~get_groups` method which creates groups to be sampled from.
docstr: Construct index of batches from which can be sampled
docstr_tok: ["Construct","index","of","batches","from","which","can","be","sampled"]
code: def construct_batch_groups(self, groups):
      """
      Construct index of batches from which can be sampled
      """
      self._groups = groups
      # calculate sizes of groups
      self._group_sizes = {}
      warns = []
      for name, group in self._groups.items():  # iterate over groups
          if self.drop_last:
              self._group_sizes[name] = len(group) // self.batch_size
          else:
              self._group_sizes[name] = (
                  len(group) + self.batch_size - 1
              ) // self.batch_size
          if self._group_sizes[name] == 0:
              self._group_sizes[name] = 1
              warns.append(name)
      if len(warns) > 0:
          warnings.warn(
              f"Less than {self.batch_size} samples available for {len(warns)} prediction times. "
              f"Use batch size smaller than {self.batch_size}. "
              f"First 10 prediction times with small batch sizes: {warns[:10]}"
          )
      # create index from which can be sampled: index is equal to number of batches
      # associate index with prediction time
      self._group_index = np.repeat(
          list(self._group_sizes.keys()),
          list(self._group_sizes.values()),
      )
      # associate index with batch within prediction time group
      self._sub_group_index = np.concatenate(
          [np.arange(size) for size in self._group_sizes.values()]
      )
  
file_path: pytorch-forecasting/pytorch_forecasting/data/samplers.py
imports: import warnings
  import numpy
  import pandas
  from sklearn.utils import shuffle
  import torch
  from torch.utils.data.sampler import Sampler
label_desc: Use image node_id 3 for calling the GroupedSampler obj's underlying member method code with example usage: obj.construct_batch_groups(groups) without return types