message: Do not record operations or watch tensors/variables when the thread tape is disabled.
diff: @@ -659,6 +659,9 @@ PyObject* TFE_Py_TapeSetShouldRecord(PyObject* tensors) {
  }
  void TFE_Py_TapeSetWatch(PyObject* tensor) {
  + if (*ThreadTapeIsStopped()) {
  + return;
  + }
  tensorflow::int64 tensor_id = FastTensorId(tensor);
  if (PyErr_Occurred()) {
  return;
  @@ -729,6 +732,9 @@ std::vector<tensorflow::int64> MakeTensorIDList(PyObject* tensors) {
  }
  void TFE_Py_TapeSetWatchVariable(PyObject* variable) {
  + if (*ThreadTapeIsStopped()) {
  + return;
  + }
  for (TFE_Py_Tape* tape : *GetTapeSet()) {
  tape->tape->WatchVariable(variable);
  }
  @@ -748,7 +754,7 @@ void TFE_Py_TapeSetRecordOperation(PyObject* op_type, PyObject* output_tensors,
  PyObject* input_tensors,
  PyObject* backward_function) {
  auto* set = GetTapeSet();
  - if (set->empty()) {
  + if (set->empty() || *ThreadTapeIsStopped()) {
  return;
  }
  std::vector<tensorflow::int64> input_ids = MakeTensorIDList(input_tensors);
  