def mse_chunked(g_r, g_i, fg_r, fg_i, fg_comps, nchunks, data_r, data_i, wgts, ant0_inds, ant1_inds, dtype=np.float32):
    cal_loss = [tf.constant(0.0, dtype) for cnum in range(nchunks)]
    for cnum in range(nchunks):
        (model_r, model_i) = data_model(g_r, g_i, fg_r[cnum], fg_i[cnum], fg_comps[cnum], ant0_inds[cnum], ant1_inds[cnum])
        cal_loss[cnum] += mse(model_r, model_i, data_r[cnum], data_i[cnum], wgts[cnum])
    return tf.reduce_sum(tf.stack(cal_loss))
def mse_chunked(g_r, g_i, fg_r, fg_i, fg_comps, nchunks, data_r, data_i, wgts, ant0_inds, ant1_inds, dtype=np.float32):
    cal_loss = [tf.constant(0.0, dtype) for cnum in range(nchunks)]
    for cnum in range(nchunks):
        (model_r, model_i) = data_model(g_r, g_i, fg_r[cnum], fg_i[cnum], fg_comps[cnum], ant0_inds[cnum], ant1_inds[cnum])
        cal_loss[cnum] += mse(model_r, model_i, data_r[cnum], data_i[cnum], wgts[cnum])
    return tf.reduce_sum(tf.stack(cal_loss))