def process_tfr(src_file: str, tgt_file: str,
                affected_labels: Collection[str]) -> Tuple[int, int]:
  """Processes examples in the TFRecord file src_file and writes to tgt_file.

  Args:
    src_file: Source TFRecord file
    tgt_file: Target TFRecord file
    affected_labels: List of labels to detect. If an exemplar has any of these
      labels, add a guiding tag.

  Returns:
    (number of affected examples, total number of examples)
  """
  num_affected = num_total = 0
  with tf.io.TFRecordWriter(tgt_file) as writer:
    for raw_example in tf.data.TFRecordDataset(src_file):
      num_total += 1
      example = tf.train.Example.FromString(raw_example.numpy())
      inputs_feature = example.features.feature["inputs"]
      input_str = inputs_feature.bytes_list.value[0].decode()
      exemplars = input_str.split(QUERY_EXEMPLARS_SEP, 1)[1]
      if any(x in exemplars for x in affected_labels):
        num_affected += 1
        input_str = input_str.replace(GUIDING_TAG_BEFORE, GUIDING_TAG_AFTER)
        inputs_feature.bytes_list.value[0] = input_str.encode()
      writer.write(example.SerializeToString())
  return num_affected, num_total
Processes examples in the TFRecord file src_file and writes to tgt_file.

  Args:
    src_file: Source TFRecord file
    tgt_file: Target TFRecord file
    affected_labels: List of labels to detect. If an exemplar has any of these
      labels, add a guiding tag.

  Returns:
    (number of affected examples, total number of examples)
  
language/casper/augment/patch_guiding_tag.py