from tensorflow.python.ops import array_ops

  # logic.
  with ops.device(None):
    if all(tensor.shape == tensor_shape.scalar() for tensor in tensors):
      with ops.device(tensors[0].device):
        values = array_ops.stack(tensors)
      with ops.device(device):
        return array_ops.unstack(values)
    else:
      with ops.device(tensors[0].device):
        sizes = array_ops.stack(
            [array_ops.shape(tensor)[0] for tensor in tensors])
        values = array_ops.concat(tensors, axis=0)
      with ops.device(device):
        sizes = array_ops.unstack(sizes)
        return list(array_ops.split(values, sizes, axis=0))


def _scheduled_stamp_resource_op_runner(batch, stamp):
  """Runs a batch operation on a stamped resource."""
  if not batch:
    return
  arg_keys = set(batch[0].args.keys())
