code: def testBasicTrainLoopRetryOnAborted(self):
      logdir = _test_dir("basic_train_loop_exception_aborts")
  
      class AbortAndRetry:
          def __init__(self):
              self.num_calls = 0
              self.retries_left = 2
  
          def train_fn(self, unused_sess):
              self.num_calls += 1
              if self.num_calls % 3 == 2:
                  self.retries_left -= 1
              if self.retries_left > 0:
                  raise errors_impl.AbortedError(
                      None, None, "Aborted here"
                  )
              else:
                  raise RuntimeError("Failed Again")
  
      with ops.Graph().as_default():
          sv = supervisor.Supervisor(logdir=logdir)
          aar = AbortAndRetry()
          with self.assertRaisesRegex(RuntimeError, "Failed Again"):
              basic_loops.basic_train_loop(sv, aar.train_fn)
          self.assertEqual(0, aar.retries_left)
  
file_path: tensorflow-upstream/tensorflow/python/training/basic_loops_test.py
imports: import os
  import shutil
  from tensorflow.python.framework import errors_impl
  from tensorflow.python.framework import ops
  from tensorflow.python.platform import test
  from tensorflow.python.training import basic_loops
  from tensorflow.python.training import supervisor
label_desc: Use image node_id 3 for calling the BasicTrainLoopTest obj's underlying member method code with example usage: obj.testBasicTrainLoopRetryOnAborted() without return types