






import argparse
import json
import os
from pathlib import Path

import requests
import torch

from transformers import JukeboxConfig, JukeboxModel
from transformers.utils import logging


logging.set_verbosity_info()
__snake_case    :    int         =     logging.get_logger(__name__)


__snake_case    :    Any         =     """https://openaipublic.azureedge.net/jukebox/models/"""
__snake_case    :    Any         =     {
    """jukebox-1b-lyrics""": [
        """5b/vqvae.pth.tar""",
        """5b/prior_level_0.pth.tar""",
        """5b/prior_level_1.pth.tar""",
        """1b_lyrics/prior_level_2.pth.tar""",
    ],
    """jukebox-5b-lyrics""": [
        """5b/vqvae.pth.tar""",
        """5b/prior_level_0.pth.tar""",
        """5b/prior_level_1.pth.tar""",
        """5b_lyrics/prior_level_2.pth.tar""",
    ],
}







def 	_UpperCamelCase   (    UpperCamelCase_       :					List[Any]		)  ->   List[Any]:

						"""simple docstring"""



						if key.endswith('.model.1.bias'		) and len(key.split('.'		)		) > 10:
												lowerCAmelCase__    						=						key.replace('.model.1.bias'    ,       '.conv1d_1.bias'		)
						elif key.endswith('.model.1.weight'		) and len(key.split('.'		)		) > 10:
												lowerCAmelCase__    						=						key.replace('.model.1.weight'    ,       '.conv1d_1.weight'		)
						elif key.endswith('.model.3.bias'		) and len(key.split('.'		)		) > 10:
												lowerCAmelCase__    						=						key.replace('.model.3.bias'    ,       '.conv1d_2.bias'		)
						elif key.endswith('.model.3.weight'		) and len(key.split('.'		)		) > 10:
												lowerCAmelCase__    						=						key.replace('.model.3.weight'    ,       '.conv1d_2.weight'		)

						if "conditioner_blocks.0." in key:
												lowerCAmelCase__    						=						key.replace('conditioner_blocks.0'    ,       'conditioner_blocks'		)

						if "prime_prior" in key:
												lowerCAmelCase__    						=						key.replace('prime_prior'    ,       'encoder'		)

						if ".emb." in key and "total" not in key and "absolute" not in key and "relative" not in key:
												lowerCAmelCase__    						=						key.replace('.emb.'    ,       '.'		)

						if key.endswith('k'		):  # replace vqvae.X.k with vqvae.X.codebook
												return key.replace('.k'    ,       '.codebook'		)
						if "y_emb." in key:
												return key.replace('y_emb.'    ,       'metadata_embedding.'		)

						if "x_emb.emb." in key:
												lowerCAmelCase__    						=						key.replace('0.x_emb.emb'    ,       'embed_tokens'		)

						if "prime_state_ln" in key:
												return key.replace('prime_state_ln'    ,       'encoder.final_layer_norm'		)
						if ".ln" in key:
												return key.replace('.ln'    ,       '.layer_norm'		)
						if "_ln" in key:
												return key.replace('_ln'    ,       '_layer_norm'		)

						if "prime_state_proj" in key:
												return key.replace('prime_state_proj'    ,       'encoder.proj_in'		)
						if "prime_x_out" in key:
												return key.replace('prime_x_out'    ,       'encoder.lm_head'		)
						if "prior.x_out" in key:
												return key.replace('x_out'    ,       'fc_proj_out'		)
						if "x_emb" in key:
												return key.replace('x_emb'    ,       'embed_tokens'		)

						return key







def 	_UpperCamelCase   (    UpperCamelCase_       :					Dict    ,       UpperCamelCase_       :					Optional[Any]    ,       UpperCamelCase_       :					str    ,       UpperCamelCase_       :					Optional[int]		)  ->   int:

						"""simple docstring"""



						lowerCAmelCase__    						=						{}
						import re

						lowerCAmelCase__    						=						re.compile(r'encoders.(\d*).level_blocks.(\d*).model.(\d*).(\d).(bias|weight)'		)
						lowerCAmelCase__    						=						re.compile(
						    r'encoders.(\d*).level_blocks.(\d*).model.(\d*).(\d).model.(\d*).model.(\d*).(bias|weight)'		)
						lowerCAmelCase__    						=						re.compile(r'encoders.(\d*).level_blocks.(\d*).model.(\d*).(bias|weight)'		)

						lowerCAmelCase__    						=						re.compile(r'decoders.(\d*).level_blocks.(\d*).model.(\d*).(\d).(bias|weight)'		)
						lowerCAmelCase__    						=						re.compile(
						    r'decoders.(\d*).level_blocks.(\d*).model.(\d*).(\d).model.(\d*).model.(\d*).(bias|weight)'		)
						lowerCAmelCase__    						=						re.compile(r'decoders.(\d*).level_blocks.(\d*).model.(\d*).(bias|weight)'		)

						lowerCAmelCase__    						=						re.compile(r'conditioner_blocks.(\d*).cond.model.(\d*).(\d).(bias|weight)'		)
						lowerCAmelCase__    						=						re.compile(
						    r'conditioner_blocks.(\d*).cond.model.(\d*).(\d).model.(\d*).model.(\d*).(bias|weight)'		)
						lowerCAmelCase__    						=						re.compile(r'conditioner_blocks.(\d*).cond.model.(\d*).(bias|weight)'		)

						for original_key, value in state_dict.items():
												# rename vqvae.encoder keys
												if re_encoder_block_conv_in.fullmatch(UpperCamelCase_		):
																		lowerCAmelCase__    						=						re_encoder_block_conv_in.match(UpperCamelCase_		)
																		lowerCAmelCase__    						=						regex_match.groups()
																		lowerCAmelCase__    						=						int(groups[2]		) * 2 + int(groups[3]		)
																		lowerCAmelCase__    						=						F"encoders.{groups[0]}.level_blocks.{groups[1]}.downsample_block.{block_index}.{groups[-1]}"
																		lowerCAmelCase__    						=						re_encoder_block_conv_in.sub(UpperCamelCase_    ,       UpperCamelCase_		)

												elif re_encoder_block_resnet.fullmatch(UpperCamelCase_		):
																		lowerCAmelCase__    						=						re_encoder_block_resnet.match(UpperCamelCase_		)
																		lowerCAmelCase__    						=						regex_match.groups()
																		lowerCAmelCase__    						=						int(groups[2]		) * 2 + int(groups[3]		)
																		lowerCAmelCase__    						=						{'1': 1, '3': 2}[groups[-2]]
																		lowerCAmelCase__    						=						F"encoders.{groups[0]}.level_blocks.{groups[1]}.downsample_block.{block_index}."
																		lowerCAmelCase__    						=						F"resnet_block.{groups[-3]}.conv1d_{conv_index}.{groups[-1]}"
																		lowerCAmelCase__    						=						prefix + resnet_block
																		lowerCAmelCase__    						=						re_encoder_block_resnet.sub(UpperCamelCase_    ,       UpperCamelCase_		)

												elif re_encoder_block_proj_out.fullmatch(UpperCamelCase_		):
																		lowerCAmelCase__    						=						re_encoder_block_proj_out.match(UpperCamelCase_		)
																		lowerCAmelCase__    						=						regex_match.groups()
																		lowerCAmelCase__    						=						F"encoders.{groups[0]}.level_blocks.{groups[1]}.proj_out.{groups[-1]}"
																		lowerCAmelCase__    						=						re_encoder_block_proj_out.sub(UpperCamelCase_    ,       UpperCamelCase_		)

												# rename vqvae.decoder keys
												elif re_decoder_block_conv_out.fullmatch(UpperCamelCase_		):
																		lowerCAmelCase__    						=						re_decoder_block_conv_out.match(UpperCamelCase_		)
																		lowerCAmelCase__    						=						regex_match.groups()
																		lowerCAmelCase__    						=						int(groups[2]		) * 2 + int(groups[3]		) - 2
																		lowerCAmelCase__    						=						F"decoders.{groups[0]}.level_blocks.{groups[1]}.upsample_block.{block_index}.{groups[-1]}"
																		lowerCAmelCase__    						=						re_decoder_block_conv_out.sub(UpperCamelCase_    ,       UpperCamelCase_		)

												elif re_decoder_block_resnet.fullmatch(UpperCamelCase_		):
																		lowerCAmelCase__    						=						re_decoder_block_resnet.match(UpperCamelCase_		)
																		lowerCAmelCase__    						=						regex_match.groups()
																		lowerCAmelCase__    						=						int(groups[2]		) * 2 + int(groups[3]		) - 2
																		lowerCAmelCase__    						=						{'1': 1, '3': 2}[groups[-2]]
																		lowerCAmelCase__    						=						F"decoders.{groups[0]}.level_blocks.{groups[1]}.upsample_block.{block_index}."
																		lowerCAmelCase__    						=						F"resnet_block.{groups[-3]}.conv1d_{conv_index}.{groups[-1]}"
																		lowerCAmelCase__    						=						prefix + resnet_block
																		lowerCAmelCase__    						=						re_decoder_block_resnet.sub(UpperCamelCase_    ,       UpperCamelCase_		)

												elif re_decoder_block_proj_in.fullmatch(UpperCamelCase_		):
																		lowerCAmelCase__    						=						re_decoder_block_proj_in.match(UpperCamelCase_		)
																		lowerCAmelCase__    						=						regex_match.groups()
																		lowerCAmelCase__    						=						F"decoders.{groups[0]}.level_blocks.{groups[1]}.proj_in.{groups[-1]}"
																		lowerCAmelCase__    						=						re_decoder_block_proj_in.sub(UpperCamelCase_    ,       UpperCamelCase_		)

												# rename prior cond.model to upsampler.upsample_block and resnet
												elif re_prior_cond_conv_out.fullmatch(UpperCamelCase_		):
																		lowerCAmelCase__    						=						re_prior_cond_conv_out.match(UpperCamelCase_		)
																		lowerCAmelCase__    						=						regex_match.groups()
																		lowerCAmelCase__    						=						int(groups[1]		) * 2 + int(groups[2]		) - 2
																		lowerCAmelCase__    						=						F"conditioner_blocks.upsampler.upsample_block.{block_index}.{groups[-1]}"
																		lowerCAmelCase__    						=						re_prior_cond_conv_out.sub(UpperCamelCase_    ,       UpperCamelCase_		)

												elif re_prior_cond_resnet.fullmatch(UpperCamelCase_		):
																		lowerCAmelCase__    						=						re_prior_cond_resnet.match(UpperCamelCase_		)
																		lowerCAmelCase__    						=						regex_match.groups()
																		lowerCAmelCase__    						=						int(groups[1]		) * 2 + int(groups[2]		) - 2
																		lowerCAmelCase__    						=						{'1': 1, '3': 2}[groups[-2]]
																		lowerCAmelCase__    						=						F"conditioner_blocks.upsampler.upsample_block.{block_index}."
																		lowerCAmelCase__    						=						F"resnet_block.{groups[-3]}.conv1d_{conv_index}.{groups[-1]}"
																		lowerCAmelCase__    						=						prefix + resnet_block
																		lowerCAmelCase__    						=						re_prior_cond_resnet.sub(UpperCamelCase_    ,       UpperCamelCase_		)

												elif re_prior_cond_proj_in.fullmatch(UpperCamelCase_		):
																		lowerCAmelCase__    						=						re_prior_cond_proj_in.match(UpperCamelCase_		)
																		lowerCAmelCase__    						=						regex_match.groups()
																		lowerCAmelCase__    						=						F"conditioner_blocks.upsampler.proj_in.{groups[-1]}"
																		lowerCAmelCase__    						=						re_prior_cond_proj_in.sub(UpperCamelCase_    ,       UpperCamelCase_		)

												# keep original key
												else:
																		lowerCAmelCase__    						=						original_key

												lowerCAmelCase__    						=						replace_key(UpperCamelCase_		)

												if F"{key_prefix}.{key}" not in model_state_dict or key is None:
																		print(F"failed converting {original_key} to {key}, does not match"		)

												# handle missmatched shape
												elif value.shape != model_state_dict[F"{key_prefix}.{key}"].shape:
																		lowerCAmelCase__    						=						model_state_dict[F"{key_prefix}.{key}"]
																		print(F"{original_key}-> {key} : \nshape {val.shape} and { value.shape}, do not match"		)
																		lowerCAmelCase__    						=						original_key

												lowerCAmelCase__    						=						original_key
												lowerCAmelCase__    						=						value

						return new_dict







@torch.no_grad()
def 	_UpperCamelCase   (    UpperCamelCase_       :					Union[str, Any]=None    ,       UpperCamelCase_       :					Optional[Any]=None		)  ->   Optional[int]:

						"""simple docstring"""



						for file in MODEL_MAPPING[model_name]:
												if not os.path.isfile(F"{pytorch_dump_folder_path}/{file.split('/'		)[-1]}"		):
																		lowerCAmelCase__    						=						requests.get(F"{PREFIX}{file}"    ,       allow_redirects=UpperCamelCase_		)
																		os.makedirs(F"{pytorch_dump_folder_path}/"    ,       exist_ok=UpperCamelCase_		)
																		open(F"{pytorch_dump_folder_path}/{file.split('/'		)[-1]}"    ,       'wb'		).write(r.content		)

						lowerCAmelCase__    						=						MODEL_MAPPING[model_name.split('/'		)[-1]]

						lowerCAmelCase__    						=						JukeboxConfig.from_pretrained(UpperCamelCase_		)
						lowerCAmelCase__    						=						JukeboxModel(UpperCamelCase_		)

						lowerCAmelCase__    						=						[]
						lowerCAmelCase__    						=						{}
						for i, dict_name in enumerate(UpperCamelCase_		):
												lowerCAmelCase__    						=						torch.load(F"{pytorch_dump_folder_path}/{dict_name.split('/'		)[-1]}"		)['model']

												lowerCAmelCase__    						=						{}
												for k in old_dic.keys():
																		if k.endswith('.b'		):
																								lowerCAmelCase__    						=						old_dic[k]
																		elif k.endswith('.w'		):
																								lowerCAmelCase__    						=						old_dic[k]
																		elif "level_2" not in dict_name and "cond.model." in k:
																								lowerCAmelCase__    						=						old_dic[k]
																		else:
																								lowerCAmelCase__    						=						old_dic[k]

												lowerCAmelCase__    						=						'vqvae' if i == 0 else F"priors.{3 - i}"
												lowerCAmelCase__    						=						fix_jukebox_keys(UpperCamelCase_    ,       model.state_dict()    ,       UpperCamelCase_    ,       UpperCamelCase_		)
												weight_dict.append(UpperCamelCase_		)

						lowerCAmelCase__    						=						weight_dict.pop(0		)
						model.vqvae.load_state_dict(UpperCamelCase_		)
						for i in range(len(UpperCamelCase_		)		):
												model.priors[i].load_state_dict(weight_dict[2 - i]		)

						Path(UpperCamelCase_		).mkdir(exist_ok=UpperCamelCase_		)
						with open(F"{pytorch_dump_folder_path}/mapping.json"    ,       'w'		) as txtfile:
												json.dump(UpperCamelCase_    ,       UpperCamelCase_		)

						print(F"Saving model {model_name} to {pytorch_dump_folder_path}"		)
						model.save_pretrained(UpperCamelCase_		)

						return weight_dict


if __name__ == "__main__":
					__snake_case    :    Optional[int]         =     argparse.ArgumentParser()
					# Required parameters
					parser.add_argument(
					    """--model_name""",
					    default="""jukebox-5b-lyrics""",
					    type=str,
					    help="""Name of the model you'd like to convert.""",
					)
					parser.add_argument(
					    """--pytorch_dump_folder_path""",
					    default="""jukebox-5b-lyrics-converted""",
					    type=str,
					    help="""Path to the output PyTorch model directory.""",
					)
					__snake_case    :    Tuple         =     parser.parse_args()
					convert_openai_checkpoint(args.model_name, args.pytorch_dump_folder_path)













from typing import Dict, Optional

import numpy as np

import datasets


__snake_case    :    str         =     """
IoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union
between the predicted segmentation and the ground truth. For binary (two classes) or multi-class segmentation,
the mean IoU of the image is calculated by taking the IoU of each class and averaging them.
"""

__snake_case    :    Tuple         =     """
Args:
    predictions (`List[ndarray]`):
        List of predicted segmentation maps, each of shape (height, width). Each segmentation map can be of a different size.
    references (`List[ndarray]`):
        List of ground truth segmentation maps, each of shape (height, width). Each segmentation map can be of a different size.
    num_labels (`int`):
        Number of classes (categories).
    ignore_index (`int`):
        Index that will be ignored during evaluation.
    nan_to_num (`int`, *optional*):
        If specified, NaN values will be replaced by the number defined by the user.
    label_map (`dict`, *optional*):
        If specified, dictionary mapping old label indices to new label indices.
    reduce_labels (`bool`, *optional*, defaults to `False`):
        Whether or not to reduce all label values of segmentation maps by 1. Usually used for datasets where 0 is used for background,
        and background itself is not included in all classes of a dataset (e.g. ADE20k). The background label will be replaced by 255.

Returns:
    `Dict[str, float | ndarray]` comprising various elements:
    - *mean_iou* (`float`):
        Mean Intersection-over-Union (IoU averaged over all categories).
    - *mean_accuracy* (`float`):
        Mean accuracy (averaged over all categories).
    - *overall_accuracy* (`float`):
        Overall accuracy on all images.
    - *per_category_accuracy* (`ndarray` of shape `(num_labels,)`):
        Per category accuracy.
    - *per_category_iou* (`ndarray` of shape `(num_labels,)`):
        Per category IoU.

Examples:

    >>> import numpy as np

    >>> mean_iou = datasets.load_metric(\"mean_iou\")

    >>> # suppose one has 3 different segmentation maps predicted
    >>> predicted_1 = np.array([[1, 2], [3, 4], [5, 255]])
    >>> actual_1 = np.array([[0, 3], [5, 4], [6, 255]])

    >>> predicted_2 = np.array([[2, 7], [9, 2], [3, 6]])
    >>> actual_2 = np.array([[1, 7], [9, 2], [3, 6]])

    >>> predicted_3 = np.array([[2, 2, 3], [8, 2, 4], [3, 255, 2]])
    >>> actual_3 = np.array([[1, 2, 2], [8, 2, 1], [3, 255, 1]])

    >>> predicted = [predicted_1, predicted_2, predicted_3]
    >>> ground_truth = [actual_1, actual_2, actual_3]

    >>> results = mean_iou.compute(predictions=predicted, references=ground_truth, num_labels=10, ignore_index=255, reduce_labels=False)
    >>> print(results) # doctest: +NORMALIZE_WHITESPACE
    {'mean_iou': 0.47750000000000004, 'mean_accuracy': 0.5916666666666666, 'overall_accuracy': 0.5263157894736842, 'per_category_iou': array([0.   , 0.   , 0.375, 0.4  , 0.5  , 0.   , 0.5  , 1.   , 1.   , 1.   ]), 'per_category_accuracy': array([0.        , 0.        , 0.75      , 0.66666667, 1.        , 0.        , 0.5       , 1.        , 1.        , 1.        ])}
"""

__snake_case    :    Any         =     """\
@software{MMSegmentation_Contributors_OpenMMLab_Semantic_Segmentation_2020,
author = {{MMSegmentation Contributors}},
license = {Apache-2.0},
month = {7},
title = {{OpenMMLab Semantic Segmentation Toolbox and Benchmark}},
url = {https://github.com/open-mmlab/mmsegmentation},
year = {2020}
}"""







def 	_UpperCamelCase   (    UpperCamelCase_       :					str    ,       UpperCamelCase_       :					Tuple    ,       UpperCamelCase_       :					Optional[Any]    ,       UpperCamelCase_       :					bool    ,       UpperCamelCase_       :					Optional[Dict[int, int]] = None    ,       UpperCamelCase_       :					bool = False    ,       )  ->   List[Any]:

						"""simple docstring"""



						if label_map is not None:
												for old_id, new_id in label_map.items():
																		lowerCAmelCase__    						=						new_id

    # turn into Numpy arrays
						lowerCAmelCase__    						=						np.array(UpperCamelCase_		)
						lowerCAmelCase__    						=						np.array(UpperCamelCase_		)

						if reduce_labels:
												lowerCAmelCase__    						=						255
												lowerCAmelCase__    						=						label - 1
												lowerCAmelCase__    						=						255

						lowerCAmelCase__    						=						label != ignore_index
						lowerCAmelCase__    						=						np.not_equal(UpperCamelCase_    ,       UpperCamelCase_		)
						lowerCAmelCase__    						=						pred_label[mask]
						lowerCAmelCase__    						=						np.array(UpperCamelCase_		)[mask]

						lowerCAmelCase__    						=						pred_label[pred_label == label]

						lowerCAmelCase__    						=						np.histogram(UpperCamelCase_    ,       bins=UpperCamelCase_    ,       range=(0, num_labels - 1)		)[0]
						lowerCAmelCase__    						=						np.histogram(UpperCamelCase_    ,       bins=UpperCamelCase_    ,       range=(0, num_labels - 1)		)[0]
						lowerCAmelCase__    						=						np.histogram(UpperCamelCase_    ,       bins=UpperCamelCase_    ,       range=(0, num_labels - 1)		)[0]

						lowerCAmelCase__    						=						area_pred_label + area_label - area_intersect

						return area_intersect, area_union, area_pred_label, area_label







def 	_UpperCamelCase   (    UpperCamelCase_       :					Dict    ,       UpperCamelCase_       :					str    ,       UpperCamelCase_       :					int    ,       UpperCamelCase_       :					bool    ,       UpperCamelCase_       :					Optional[Dict[int, int]] = None    ,       UpperCamelCase_       :					bool = False    ,       )  ->   Union[str, Any]:

						"""simple docstring"""



						lowerCAmelCase__    						=						np.zeros((num_labels,)    ,       dtype=np.floataa		)
						lowerCAmelCase__    						=						np.zeros((num_labels,)    ,       dtype=np.floataa		)
						lowerCAmelCase__    						=						np.zeros((num_labels,)    ,       dtype=np.floataa		)
						lowerCAmelCase__    						=						np.zeros((num_labels,)    ,       dtype=np.floataa		)
						for result, gt_seg_map in zip(UpperCamelCase_    ,       UpperCamelCase_		):
												lowerCAmelCase__						,       lowerCAmelCase__						,       lowerCAmelCase__						,       lowerCAmelCase__    						=						intersect_and_union(
												    UpperCamelCase_    ,       UpperCamelCase_    ,       UpperCamelCase_    ,       UpperCamelCase_    ,       UpperCamelCase_    ,       UpperCamelCase_		)
												total_area_intersect += area_intersect
												total_area_union += area_union
												total_area_pred_label += area_pred_label
												total_area_label += area_label
						return total_area_intersect, total_area_union, total_area_pred_label, total_area_label







def 	_UpperCamelCase   (    UpperCamelCase_       :					List[str]    ,       UpperCamelCase_       :					Optional[int]    ,       UpperCamelCase_       :					str    ,       UpperCamelCase_       :					bool    ,       UpperCamelCase_       :					Optional[int] = None    ,       UpperCamelCase_       :					Optional[Dict[int, int]] = None    ,       UpperCamelCase_       :					bool = False    ,       )  ->   List[str]:

						"""simple docstring"""



						lowerCAmelCase__						,       lowerCAmelCase__						,       lowerCAmelCase__						,       lowerCAmelCase__    						=						total_intersect_and_union(
						    UpperCamelCase_    ,       UpperCamelCase_    ,       UpperCamelCase_    ,       UpperCamelCase_    ,       UpperCamelCase_    ,       UpperCamelCase_		)

						# compute metrics
						lowerCAmelCase__    						=						{}

						lowerCAmelCase__    						=						total_area_intersect.sum() / total_area_label.sum()
						lowerCAmelCase__    						=						total_area_intersect / total_area_union
						lowerCAmelCase__    						=						total_area_intersect / total_area_label

						lowerCAmelCase__    						=						np.nanmean(UpperCamelCase_		)
						lowerCAmelCase__    						=						np.nanmean(UpperCamelCase_		)
						lowerCAmelCase__    						=						all_acc
						lowerCAmelCase__    						=						iou
						lowerCAmelCase__    						=						acc

						if nan_to_num is not None:
												lowerCAmelCase__    						=						{metric: np.nan_to_num(UpperCamelCase_    ,       nan=UpperCamelCase_		) for metric, metric_value in metrics.items()}

						return metrics


@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION		,					_KWARGS_DESCRIPTION)
class     __SCREAMING_SNAKE_CASE					(   datasets.Metric):






						def       UpperCamelCase__      (	self   ):






												"""simple docstring"""
												return datasets.MetricInfo(
												    description=_DESCRIPTION     ,						citation=_CITATION     ,						inputs_description=_KWARGS_DESCRIPTION     ,						features=datasets.Features(
												        # 1st Seq - height dim, 2nd - width dim
												        {
												            'predictions': datasets.Sequence(datasets.Sequence(datasets.Value('uint16'   )   )   ),
												            'references': datasets.Sequence(datasets.Sequence(datasets.Value('uint16'   )   )   ),
												        }   )     ,						reference_urls=[
												        'https://github.com/open-mmlab/mmsegmentation/blob/71c201b1813267d78764f306a297ca717827c4bf/mmseg/core/evaluation/metrics.py'
												    ]     ,						)







						def       UpperCamelCase__      (	self     ,						_UpperCamelCase     ,						_UpperCamelCase     ,						_UpperCamelCase     ,						_UpperCamelCase     ,						_UpperCamelCase = None     ,						_UpperCamelCase = None     ,						_UpperCamelCase = False     ,						):






												"""simple docstring"""
												lowerCAmelCase__    						=						mean_iou(
												    results=_UpperCamelCase     ,						gt_seg_maps=_UpperCamelCase     ,						num_labels=_UpperCamelCase     ,						ignore_index=_UpperCamelCase     ,						nan_to_num=_UpperCamelCase     ,						label_map=_UpperCamelCase     ,						reduce_labels=_UpperCamelCase     ,						)
												return iou_result





