same Error as #35100 --W tensorflow/core/kernels/data/generator_dataset_op.cc:107] Error occurred when finalizing GeneratorDataset iterator: Failed precondition: Python interpreter state is not initialized. The process may be terminated. 	 [[{{node PyFunc}}]]
Hi @AnwarsaeedDMU ,

Currently we are not supporting TF 1.x versions. Could you please migrate to TF2.x versions using the migration [guide](https://www.tensorflow.org/guide/migrate) and then report the issue with the changed code.

Thanks! This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/60702">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/60702">No</a>

I am reproducing the [code](https://github.com/weizhepei/CasRel) , I followed there requirement but when code reached to 44/100 epoch I got this error : `2023-05-24 06:42:29.554799: W tensorflow/core/kernels/data/generator_dataset_op.cc:107] Error occurred when finalizing GeneratorDataset iterator: Failed precondition: Python interpreter state is not initialized. The process may be terminated. 	 [[{{node PyFunc}}]]`. I tried to to update tensorflow but it stop working because of keras version. 
Code requirements: 
`Package                          Version
-------------------------------- ---------
absl-py                          1.4.0
astor                            0.8.1
certifi                          2022.12.7
charset-normalizer               3.1.0
colorama                         0.4.6
filelock                         3.12.0
fsspec                           2023.1.0
gast                             0.5.3
google-pasta                     0.2.0
grpcio                           1.51.3
h5py                             3.8.0
huggingface-hub                  0.14.1
idna                             3.4
importlib-metadata               6.0.0
joblib                           1.2.0
Keras                            2.2.4
Keras-Applications               1.0.8
keras-bert                       0.80.0
keras-embed-sim                  0.10.0
keras-layer-normalization        0.16.0
keras-multi-head                 0.29.0
keras-pos-embd                   0.13.0
keras-position-wise-feed-forward 0.8.0
Keras-Preprocessing              1.1.2
keras-self-attention             0.51.0
keras-transformer                0.33.0
Markdown                         3.4.1
MarkupSafe                       2.1.2
mock                             5.0.1
numpy                            1.21.6
packaging                        23.1
pip                              22.3.1
protobuf                         3.20.1
PyYAML                           6.0
regex                            2023.5.5
requests                         2.31.0
scikit-learn                     1.0.2
scipy                            1.7.3
setuptools                       65.6.3
six                              1.16.0
sklearn                          0.0.post5
tensorboard                      1.13.1
tensorflow-estimator             1.13.0
tensorflow-gpu                   1.13.1
termcolor                        2.2.0
threadpoolctl                    3.1.0
tokenizers                       0.13.3
torch                            1.13.1
tqdm                             4.65.0
transformers                     4.29.2
typing_extensions                4.5.0
urllib3                          2.0.2
Werkzeug                         2.2.3
wheel                            0.38.4
wincertstore                     0.2
wrapt                            1.15.0
zipp                             3.15.0
`

and run.py code is: 
`#! -*- coding:utf-8 -*-
from data_loader import data_generator, load_data
from model import E2EModel, Evaluate
from utils import extract_items, get_tokenizer, metric
import os, argparse
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
from keras import backend as K
if(K.backend() == 'tensorflow'):
    import tensorflow as tf
    from keras.backend.tensorflow_backend import set_session
    config = tf.ConfigProto()
    config.gpu_options.allow_growth = True
    sess = tf.Session(config=config)


    #tried these lines too but not useful
    '''config = tf.compat.v1.ConfigProto(gpu_options=tf.compat.v1.GPUOptions(allow_growth=True))
    sess = tf.compat.v1.Session(config=config)'''

parser = argparse.ArgumentParser(description='Model Controller')
parser.add_argument('--train', default=True, type=bool, help='to train the HBT model, python run.py --train=True')
parser.add_argument('--dataset', default='VKG', type=str, help='specify the dataset from ["NYT","WebNLG","ACE04","NYT10-HRL","NYT11-HRL","Wiki-KBP"]')
args = parser.parse_args()


if __name__ == '__main__':
    # pre-trained bert model config
    bert_model = 'cased_L-12_H-768_A-12'
    bert_config_path = 'pretrained_bert_models/' + bert_model + '/bert_config.json'
    bert_vocab_path = 'pretrained_bert_models/' + bert_model + '/vocab.txt'
    bert_checkpoint_path = 'pretrained_bert_models/' + bert_model + '/bert_model.ckpt'

    dataset = args.dataset
    train_path = 'data/' + dataset + '/train_triples.json'
    dev_path = 'data/' + dataset + '/dev_triples.json'
    #test_path = 'data/' + dataset + '/test_split_by_num/test_triples_5.json' # ['1','2','3','4','5']
    #test_path = 'data/' + dataset + '/test_split_by_type/test_triples_seo.json' # ['normal', 'seo', 'epo']
    test_path = 'data/' + dataset + '/test_triples.json' # overall test
    rel_dict_path = 'data/' + dataset + '/rel2id.json'
    save_weights_path = 'saved_weights/' + dataset + '/best_model.weights'
    
    LR = 1e-5
    tokenizer = get_tokenizer(bert_vocab_path)
    train_data, dev_data, test_data, id2rel, rel2id, num_rels = load_data(train_path, dev_path, test_path, rel_dict_path)
    subject_model, object_model, hbt_model = E2EModel(bert_config_path, bert_checkpoint_path, LR, num_rels)
    
    if args.train:
        BATCH_SIZE = 6
        EPOCH = 100
        MAX_LEN = 100
        STEPS = len(train_data) // BATCH_SIZE
        data_manager = data_generator(train_data, tokenizer, rel2id, num_rels, MAX_LEN, BATCH_SIZE)
        evaluator = Evaluate(subject_model, object_model, tokenizer, id2rel, dev_data, save_weights_path)
        hbt_model.fit_generator(data_manager.__iter__(),
                              steps_per_epoch=STEPS,
                              epochs=EPOCH,
                              callbacks=[evaluator]
                              )
    else:
        hbt_model.load_weights(save_weights_path)
        test_result_path = 'results/' + dataset + '/test_result.json'
        isExactMatch = True if dataset == 'Wiki-KBP' else False
        if isExactMatch:
            print("Exact Match")
        else:
            print("Partial Match")
        precision, recall, f1_score = metric(subject_model, object_model, test_data, id2rel, tokenizer, isExactMatch, test_result_path)
        print(f'{precision}\t{recall}\t{f1_score}')

`
#35100 