# Path: third_party/bi_att_flow/my/tensorflow/general.py
# def grouper(iterable, n, fillvalue=None, shorten=False, num_groups=None):
#   args = [iter(iterable)] * n
#   out = zip_longest(*args, fillvalue=fillvalue)
#   out = list(out)
#   if num_groups is not None:
#     default = (fillvalue,) * n
#     assert isinstance(num_groups, int)
#     out = list(
#         each
#         for each, _ in zip_longest(out, range(num_groups), fillvalue=default))
#   if shorten:
#     assert fillvalue is None
#     out = (tuple(e for e in each if e is not None) for each in out)
#   return out
# 
# Path: third_party/bi_att_flow/my/utils.py
# def index(l, i):
#   return index(l[i[0]], i[1:]) if len(i) > 1 else l[i[0]]


import json
import os
import random
import itertools
import math
import numpy as np
import tensorflow as tf
from collections import defaultdict
from third_party.bi_att_flow.my.tensorflow.general import grouper
from third_party.bi_att_flow.my.utils import index
      batch_idxs = tuple(i for i in next(batch_idx_tuples) if i is not None)
      batch_data = self.get_by_idxs(batch_idxs)
      shared_batch_data = {}
      for key, val in batch_data.items():
        if key.startswith('*'):
          if key == '*cx' and 'cx' not in self.shared:
            continue
          assert self.shared is not None
          shared_key = key[1:]
          shared_batch_data[shared_key] = [
              index(self.shared[shared_key], each) for each in val
          ]
      batch_data.update(shared_batch_data)
      batch_ds = DataSet(batch_data, self.data_type, shared=self.shared)
      yield batch_idxs, batch_ds

  def get_multi_batches(self,
                        batch_size,
                        num_batches_per_step,
                        num_steps=None,
                        shuffle=False,
                        cluster=False):
    batch_size_per_step = batch_size * num_batches_per_step
    batches = self.get_batches(
        batch_size_per_step,
        num_batches=num_steps,
        shuffle=shuffle,
        cluster=cluster)
    multi_batches = (tuple(
        zip(

# Path: third_party/bi_att_flow/my/tensorflow/general.py
# def grouper(iterable, n, fillvalue=None, shorten=False, num_groups=None):
#   args = [iter(iterable)] * n
#   out = zip_longest(*args, fillvalue=fillvalue)
#   out = list(out)
#   if num_groups is not None:
#     default = (fillvalue,) * n
#     assert isinstance(num_groups, int)
#     out = list(
#         each
#         for each, _ in zip_longest(out, range(num_groups), fillvalue=default))
#   if shorten:
#     assert fillvalue is None
#     out = (tuple(e for e in each if e is not None) for each in out)
#   return out
# 
# Path: third_party/bi_att_flow/my/utils.py
# def index(l, i):
#   return index(l[i[0]], i[1:]) if len(i) > 1 else l[i[0]]


# Path: third_party/bi_att_flow/basic/read_data.py
import json
import os
import random
import itertools
import math
import numpy as np
import tensorflow as tf
from collections import defaultdict
from third_party.bi_att_flow.my.tensorflow.general import grouper
from third_party.bi_att_flow.my.utils import index

      batch_idxs = tuple(i for i in next(batch_idx_tuples) if i is not None)
      batch_data = self.get_by_idxs(batch_idxs)
      shared_batch_data = {}
      for key, val in batch_data.items():
        if key.startswith('*'):
          if key == '*cx' and 'cx' not in self.shared:
            continue
          assert self.shared is not None
          shared_key = key[1:]
          shared_batch_data[shared_key] = [
              index(self.shared[shared_key], each) for each in val
          ]
      batch_data.update(shared_batch_data)
      batch_ds = DataSet(batch_data, self.data_type, shared=self.shared)
      yield batch_idxs, batch_ds

  def get_multi_batches(self,
                        batch_size,
                        num_batches_per_step,
                        num_steps=None,
                        shuffle=False,
                        cluster=False):
    batch_size_per_step = batch_size * num_batches_per_step
    batches = self.get_batches(
        batch_size_per_step,
        num_batches=num_steps,
        shuffle=shuffle,
        cluster=cluster)
    multi_batches = (tuple(
        zip(

            grouper(