class_docstr: Batch indices container class (used to implement packed batches)
class_docstr_tok: ["Batch","indices","container","class","(","used","to","implement","packed","batches",")"]
code: def __init__(self, batch_idxs_np, device):
      self.batch_idxs_np = batch_idxs_np
      self.batch_idxs_torch = torch.as_tensor(
          batch_idxs_np, dtype=torch.long, device=device
      )
  
      self.batch_size = int(1 + np.max(batch_idxs_np))
  
      batch_idxs_np_extra = np.concatenate([[-1], batch_idxs_np, [-1]])
      self.boundaries_np = np.nonzero(
          batch_idxs_np_extra[1:] != batch_idxs_np_extra[:-1]
      )[0]
  
      # print(f"boundaries_np: {self.boundaries_np}")
      # print(f"boundaries_np[1:]: {self.boundaries_np[1:]}")
      # print(f"boundaries_np[:-1]: {self.boundaries_np[:-1]}")
      self.seq_lens_np = (
          self.boundaries_np[1:] - self.boundaries_np[:-1]
      )
      # print(f"seq_lens_np: {self.seq_lens_np}")
      # print(f"batch_size: {self.batch_size}")
      assert len(self.seq_lens_np) == self.batch_size
      self.max_len = int(
          np.max(self.boundaries_np[1:] - self.boundaries_np[:-1])
      )
  
imports: import numpy
  import functools
  import sys
  import torch
  from torch.autograd import Variable
  import torch.nn
  import torch.nn.init
label_desc: Use image node_id 1 to create a new BatchIndices object  with example: obj = BatchIndices(batch_idxs_np, device)