<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _make_examples(bam_file, data, ref_file, region_bed, out_file, work_dir):
 """Create example pileup images to feed into variant calling. """

    log_dir = utils.safe_makedir(os.path.join(work_dir, "log"))
    example_dir = utils.safe_makedir(os.path.join(work_dir, "examples"))
    if len(glob.glob(os.path.join(example_dir, "%s.tfrecord*.gz" % dd.get_sample_name(data)))) == 0:
        with tx_tmpdir(data) as tx_example_dir:
            cmd = ["dv_make_examples.py", "--cores", dd.get_num_cores(data), "--ref", ref_file,
                   "--reads", bam_file, "--regions", region_bed, "--logdir", log_dir,
                   "--examples", tx_example_dir, "--sample", dd.get_sample_name(data)]
            do.run(cmd, "DeepVariant make_examples %s" % dd.get_sample_name(data))
            for fname in glob.glob(os.path.join(tx_example_dir, "%s.tfrecord*.gz" % dd.get_sample_name(data))):
                utils.copy_plus(fname, os.path.join(example_dir, os.path.basename(fname)))
    return example_dir