# Path: prompt_tuning/data/constants.py
# PREDICTION = "prediction"
# PREDICTION_TEXT = "prediction_pretokenized"
# INPUT_FIELD = "inputs"
# INPUT_TEXT = "inputs_pretokenized"
# TARGET_FIELD = "targets"
# TARGET_TEXT = "targets_pretokenized"
# CONTEXT_TEXT = "context"
# QUESTION_TEXT = "question"
# ANSWERS_TEXT = "answers"
# EXTRA_ID_0 = "<extra_id_0>"
# EQUIVALENT = "equivalent"
# DUPLICATE = "duplicate"


import itertools
import random
import textwrap
import seqio
import six
from typing import Sequence, Optional, Dict, List, Mapping, Any
from prompt_tuning.data import constants
# Copyright 2022 Google.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""T5 metric functions that output text examples.

These metrics functions are designed to understand that the output from the
postprocssing function will be a dict with the prediction as one field and text
examples for the others.

There is a metric function wrapper that extracts predictions from a dict and
hands it off to a real metric function. There are also metric functions that
produce a Text object that will be written to tensorboard.
"""



def metric_with_examples(metric_fn,
                         targets,
                         predictions,

# Path: prompt_tuning/data/constants.py
# PREDICTION = "prediction"
# PREDICTION_TEXT = "prediction_pretokenized"
# INPUT_FIELD = "inputs"
# INPUT_TEXT = "inputs_pretokenized"
# TARGET_FIELD = "targets"
# TARGET_TEXT = "targets_pretokenized"
# CONTEXT_TEXT = "context"
# QUESTION_TEXT = "question"
# ANSWERS_TEXT = "answers"
# EXTRA_ID_0 = "<extra_id_0>"
# EQUIVALENT = "equivalent"
# DUPLICATE = "duplicate"


# Path: prompt_tuning/data/metrics.py
import itertools
import random
import textwrap
import seqio
import six
from typing import Sequence, Optional, Dict, List, Mapping, Any
from prompt_tuning.data import constants

# Copyright 2022 Google.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""T5 metric functions that output text examples.

These metrics functions are designed to understand that the output from the
postprocssing function will be a dict with the prediction as one field and text
examples for the others.

There is a metric function wrapper that extracts predictions from a dict and
hands it off to a real metric function. There are also metric functions that
produce a Text object that will be written to tensorboard.
"""



def metric_with_examples(metric_fn,
                         targets,
                         predictions,

                         prediction_field: str = constants.PREDICTION):