# Path: mimic3models/metrics.py
# def print_metrics_binary(y_true, predictions, verbose=1):
# def print_metrics_multilabel(y_true, predictions, verbose=1):
# def mean_absolute_percentage_error(y_true, y_pred):
# def print_metrics_regression(y_true, predictions, verbose=1):
# def get_bin_log(x, nbins, one_hot=False):
# def get_estimate_log(prediction, nbins):
# def print_metrics_log_bins(y_true, predictions, verbose=1):
# def get_bin_custom(x, nbins, one_hot=False):
# def get_estimate_custom(prediction, nbins):
# def print_metrics_custom_bins(y_true, predictions, verbose=1):
# class LogBins:
# class CustomBins:
# 
# Path: mimic3models/common_utils.py
# def convert_to_dict(data, header, channel_info):
# def extract_features_from_rawdata(chunk, header, period, features):
# def read_chunk(reader, chunk_size):
# def sort_and_shuffle(data, batch_size):
# def add_common_arguments(parser):
#     def __init__(self, dataset_dir, listfile=None, small_part=False):
#     def _read_timeseries(self, ts_filename):
# def create_directory(directory):
# def pad_zeros(arr, min_length=None):
# class DeepSupervisionDataLoader:


from mimic3models import metrics
from mimic3models import common_utils
import numpy as np
import threading
import random
                # X
                X = self.data['X'][i:i+B]
                X = common_utils.pad_zeros(X, min_length=self.ihm_pos + 1)
                T = X.shape[1]

                # ihm
                ihm_M = np.array(self.data['ihm_M'][i:i+B])
                ihm_M = np.expand_dims(ihm_M, axis=-1)  # (B, 1)
                ihm_y = np.array(self.data['ihm_y'][i:i+B])
                ihm_y = np.expand_dims(ihm_y, axis=-1)  # (B, 1)
                outputs.append(ihm_y)
                if self.target_repl:
                    ihm_seq = np.expand_dims(ihm_y, axis=-1).repeat(T, axis=1)  # (B, T, 1)
                    outputs.append(ihm_seq)

                # decomp
                decomp_M = self.data['decomp_M'][i:i+B]
                decomp_M = common_utils.pad_zeros(decomp_M, min_length=self.ihm_pos + 1)
                decomp_y = self.data['decomp_y'][i:i+B]
                decomp_y = common_utils.pad_zeros(decomp_y, min_length=self.ihm_pos + 1)
                decomp_y = np.expand_dims(decomp_y, axis=-1)  # (B, T, 1)
                outputs.append(decomp_y)

                # los
                los_M = self.data['los_M'][i:i+B]
                los_M = common_utils.pad_zeros(los_M, min_length=self.ihm_pos + 1)
                los_y = self.data['los_y'][i:i+B]
                los_y_true = common_utils.pad_zeros(los_y, min_length=self.ihm_pos + 1)

                if self.partition == 'log':

# Path: mimic3models/metrics.py
# def print_metrics_binary(y_true, predictions, verbose=1):
# def print_metrics_multilabel(y_true, predictions, verbose=1):
# def mean_absolute_percentage_error(y_true, y_pred):
# def print_metrics_regression(y_true, predictions, verbose=1):
# def get_bin_log(x, nbins, one_hot=False):
# def get_estimate_log(prediction, nbins):
# def print_metrics_log_bins(y_true, predictions, verbose=1):
# def get_bin_custom(x, nbins, one_hot=False):
# def get_estimate_custom(prediction, nbins):
# def print_metrics_custom_bins(y_true, predictions, verbose=1):
# class LogBins:
# class CustomBins:
# 
# Path: mimic3models/common_utils.py
# def convert_to_dict(data, header, channel_info):
# def extract_features_from_rawdata(chunk, header, period, features):
# def read_chunk(reader, chunk_size):
# def sort_and_shuffle(data, batch_size):
# def add_common_arguments(parser):
#     def __init__(self, dataset_dir, listfile=None, small_part=False):
#     def _read_timeseries(self, ts_filename):
# def create_directory(directory):
# def pad_zeros(arr, min_length=None):
# class DeepSupervisionDataLoader:


# Path: mimic3models/multitask/utils.py
from mimic3models import metrics
from mimic3models import common_utils
import numpy as np
import threading
import random

                # X
                X = self.data['X'][i:i+B]
                X = common_utils.pad_zeros(X, min_length=self.ihm_pos + 1)
                T = X.shape[1]

                # ihm
                ihm_M = np.array(self.data['ihm_M'][i:i+B])
                ihm_M = np.expand_dims(ihm_M, axis=-1)  # (B, 1)
                ihm_y = np.array(self.data['ihm_y'][i:i+B])
                ihm_y = np.expand_dims(ihm_y, axis=-1)  # (B, 1)
                outputs.append(ihm_y)
                if self.target_repl:
                    ihm_seq = np.expand_dims(ihm_y, axis=-1).repeat(T, axis=1)  # (B, T, 1)
                    outputs.append(ihm_seq)

                # decomp
                decomp_M = self.data['decomp_M'][i:i+B]
                decomp_M = common_utils.pad_zeros(decomp_M, min_length=self.ihm_pos + 1)
                decomp_y = self.data['decomp_y'][i:i+B]
                decomp_y = common_utils.pad_zeros(decomp_y, min_length=self.ihm_pos + 1)
                decomp_y = np.expand_dims(decomp_y, axis=-1)  # (B, T, 1)
                outputs.append(decomp_y)

                # los
                los_M = self.data['los_M'][i:i+B]
                los_M = common_utils.pad_zeros(los_M, min_length=self.ihm_pos + 1)
                los_y = self.data['los_y'][i:i+B]
                los_y_true = common_utils.pad_zeros(los_y, min_length=self.ihm_pos + 1)

                if self.partition == 'log':

                    los_y = [np.array([metrics.get_bin_log(x, 10) for x in z]) for z in los_y]