<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _image_summary(self, tf_name, images, step=None):
 """ Log a list of images. References: https://github.com/yunjey/pytorch-tutorial/blob/master/tutorials/04-utils/tensorboard/logger.py#L22 Example: """

        img_summaries = []
        for i, img in enumerate(images):
            # Write the image to a string
            try:
                s = StringIO()
            except:
                s = BytesIO()
            scipy.misc.toimage(img).save(s, format="png")

            # Create an Image object
            img_sum = summary_pb2.Summary.Image(
                encoded_image_string=s.getvalue(),
                height=img.shape[0],
                width=img.shape[1]
            )
            # Create a Summary value
            img_value = summary_pb2.Summary.Value(tag='{}/{}'.format(tf_name, i),
                                                  image=img_sum)
            img_summaries.append(img_value)
            summary = summary_pb2.Summary()
            summary.value.add(tag=tf_name, image=img_sum)

        summary = summary_pb2.Summary(value=img_summaries)
        return summary