[{'role': 'system', 'content': "You are an expert in machine learning and your task is to classify code snippets into one of the following categories: ['helper_functions', 'load_data', 'data_exploration', 'data_preprocessing', 'evaluation', 'modelling', 'prediction', 'result_visualization', 'save_results', 'comment_only']."}, {'role': 'user', 'content': "Identify the single most appropriate category to which the provided code belongs. Provide your response as a single category label without any additional information, commentary, or personal opinions.\\nPython Code:def binarize_tensor(arr, threshold=0.7):\nreturn numpy.where(arr >= threshold, 1, 0)\ndef to_grayscale(arr):\nreturn arr.mean(axis=-1)\ndef identity(x):\nreturn x\ndef rgba_to_rgb(image, color=(255, 255, 255)):\nimage.load()  # needed for split()\nbackground = Image.new('RGB', image.size, color)\nbackground.paste(image, mask=image.split()[3])  # 3 is the alpha channel\nreturn background\ndef la_to_l(image, color=255):\nimage.load()  # needed for split()\nbackground = Image.new('L', image.size, color)\nbackground.paste(image, mask=image.split()[-1])  # 3 is the alpha channel\nreturn background\ndef load_image_to_array(fname, proc=identity, mode=None):\nimg = Image.open(fname)\nif not mode is None and img.mode != mode:\nif img.mode == 'LA':\nimg = la_to_l(img)\nelif img.mode == 'RGBA':\nimg = rgba_to_rgb(img)\nimg = img.convert(mode)\nreturn proc(numpy.array(img))\nfooter  = numpy.array([255,   0,   0,   0], dtype='uint8')\nheader  = numpy.array([  0, 255,   0,   0], dtype='uint8')\nbody    = numpy.array([  0,   0, 255,   0], dtype='uint8')\nnothing = numpy.array([  0,   0,   0, 255], dtype='uint8')\ndef color_to_gold_output(pixel):\nif all(pixel > 200): # body\nreturn body\nelif pixel[1] > 200: # header\nreturn header\nelif pixel[0] > 200: # footer\nreturn footer\nelse:\nreturn nothing\nfooter_and_header2  = numpy.array([255,   0,   0], dtype='uint8')\nbody2               = numpy.array([  0, 255,   0], dtype='uint8')\nnothing2            = numpy.array([  0,   0, 255], dtype='uint8')\ndef color_to_gold_output_join_fh(pixel):\nif all(pixel > 200): # body\nreturn body2\nelif pixel[1] > 200:\nreturn footer_and_header2\nelif pixel[0] > 200:\nreturn footer_and_header2\nelse:\nreturn nothing2\ndef prepare_multioutput(image):\nreturn numpy.apply_along_axis(color_to_gold_output, -1, image)\ndef prepare_multioutput2(image):\nreturn numpy.apply_along_axis(color_to_gold_output_join_fh, -1, image)\ndef read_images_to_tensor(filenames, n_jobs=20, proc=identity, mode='RGB'):\ndata = list(Parallel(n_jobs=n_jobs)(delayed(load_image_to_array)(fname, proc=proc, mode=mode)\nfor fname in filenames))\nreturn numpy.stack(data).astype('float32') / 255.0\ndef load_dataset(dirname, n_jobs=20, take_n=None, in_mode='L', out_mode='RGB', in_proc_func=identity, out_proc_func=prepare_multioutput2):\nprefixes = [fname[:-7] for fname\nin glob.glob(os.path.join(dirname, '*_in.png'))\n]\nrandom.shuffle(prefixes)\nif not take_n is None:\ntake_n = min(len(prefixes), take_n)\nelse:\ntake_n = len(prefixes)\nprefixes = prefixes[:take_n]\nin_files = [prefix + '_in.png' for prefix in prefixes]\nout_files = [prefix + '_out.png' for prefix in prefixes]\nin_data = read_images_to_tensor(in_files, n_jobs=n_jobs, proc=in_proc_func, mode=in_mode)\nout_data = read_images_to_tensor(out_files, n_jobs=n_jobs, proc=out_proc_func, mode=out_mode)\nreturn (numpy.expand_dims(in_data, -1),\nnumpy.expand_dims(out_data, -1))\ndef convert_directory_to_hdf5(dirname, out_file, chunk_size=10000, n_jobs=20, in_mode='L', out_mode='RGB', in_proc_func=identity, out_proc_func=prepare_multioutput2):\nprefixes = [fname[:-7] for fname\nin glob.glob(os.path.join(dirname, '*_in.png'))\n]\nrandom.shuffle(prefixes)\nsamples_n = len(prefixes)\nin_files = [prefix + '_in.png' for prefix in prefixes]\nout_files = [prefix + '_out.png' for prefix in prefixes]\nin_shape = load_image_to_array(in_files[0],\nproc=in_proc_func,\nmode=in_mode).shape + (1,)\nout_shape = load_image_to_array(out_files[0],\nproc=out_proc_func,\nmode=out_mode).shape\nwith h5py.File(out_file, 'w') as f:\nin_data = f.create_dataset('in_data', (samples_n,) + in_shape)\nout_data = f.create_dataset('out_data', (samples_n,) + out_shape)\nfor chunk_start in range(0, samples_n, chunk_size):\nchunk_end = min(chunk_start + chunk_size, samples_n)\nin_data[chunk_start:chunk_end] = numpy.expand_dims(\nread_images_to_tensor(in_files[chunk_start:chunk_end],\nn_jobs=n_jobs,\nproc=in_proc_func,\nmode=in_mode),\n-1)\nout_data[chunk_start:chunk_end] = read_images_to_tensor(out_files[chunk_start:chunk_end],\nn_jobs=n_jobs,\nproc=out_proc_func,\nmode=out_mode)\ndef arr_to_img(arr):\nreturn Image.fromarray((arr * 255).astype('uint8'))\ndef arr3_to_img(arr):\narr = numpy.rollaxis(arr, 0, 2).reshape((arr.shape[1], arr.shape[0] * arr.shape[2])+arr.shape[3:])\nprint(arr.shape)\nreturn arr_to_img(arr)"}, {'role': 'assistant', 'content': 'load_data'}]