<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def save_target_classes_for_batch(self, filename, image_batches, batch_id):
 """Saves file with target class for given dataset batch. Args: filename: output filename image_batches: instance of ImageBatchesBase with dataset batches batch_id: dataset batch ID """

    images = image_batches.data[batch_id]['images']
    with open(filename, 'w') as f:
      for image_id, image_val in iteritems(images):
        target_class = self.get_target_class(image_val['dataset_image_id'])
        f.write('{0}.png,{1}\n'.format(image_id, target_class))