AttributeError: module ‘tensorboard.summary._tf.summary‘ has no attribute ‘merge‘

AttributeError: module ‘tensorboard.summary._tf.summary‘ has no attribute ‘merge‘
环境是TensorFlow2.9
github上要跑的代码TensorFlow环境是1.x
很多api都无法调用

原代码

train_summary_op = tf.summary.merge([loss_summary])

报错

AttributeError: module ‘tensorboard.summary._tf.summary‘ has no attribute ‘merge‘

使用网友建议的方法:将源代码修改如下

train_summary_op = tf.compat.v1.summary.merge([loss_summary])

报错

TypeError: Tensors in list passed to 'inputs' of 'MergeSummary' Op have types [bool] that do not match expected type string.

又试了另一个方法

import tensorflow as tf
#修改为如下
import tensorflow._api.v2.compat.v1 as tf
tf.disable_v2_behavior()

之后再调用别的api就会报错

请问该怎么解决?