def make_reference(utt_tensor, diarization, spkidx, meeting_scale):
    """Makes a reference from fixed length utterance tensors.

    Args:
      utt_tensor: Utterances with shape
        (max_num_utt_per_spk, num_mics, samples + max_utt_len)
      diarization: Diarization ranges with shape
        (max_num_utt_per_spk, max_dia_seg_per_utt, 2).
      spkidx: Speaker indices (repeated) with shape (max_num_utt_per_spk)
      meeting_scale: Target meeting scale (repeated).
    Returns:
      reference: Meeting audio with shape (num_mics, samples)
      diarization_labels: tf.bool with shape (samples)
      spkidx: Scalar speaker index.
      meeting_scale: Target meeting scale.
    """
    reference_waveform = tf.reduce_sum(utt_tensor, axis=0)
    reference_waveform = reference_waveform[:, :samples]
    diarization = tf.reshape(diarization,
                             (max_num_utt_per_spk * max_dia_seg_per_utt, 2))
    active_samples_list = [
        tf.range(diarization[i, 0], diarization[i, 1]) for i in
        range(max_num_utt_per_spk * max_dia_seg_per_utt)]
    active_samples = tf.reshape(
        tf.concat(active_samples_list, axis=0), (-1, 1))
    dia_full_init = tf.zeros((samples + max_utt_length, 1), dtype=tf.int32)
    dia_full = tf.tensor_scatter_add(
        dia_full_init, active_samples, tf.ones(tf.shape(active_samples),
                                               dtype=tf.int32))
    dia_full = tf.cast(dia_full[:samples, 0], dtype=tf.bool)
    spkidx = spkidx[0]
    meeting_scale = meeting_scale[0]
    return reference_waveform, dia_full, spkidx, meeting_scale