class_docstr: Tensorflow session that runs tpu.rewrite() on ops on run().
class_docstr_tok: ["Tensorflow","session","that","runs","tpu.rewrite","(",")","on","ops","on","run","(",")","."]
code: def run(
      self, fetches, feed_dict=None, options=None, run_metadata=None
  ):
      from tensorflow.python.tpu import (
          tpu,
      )  # pylint: disable=g-import-not-at-top
  
      if self.topology is None:
          self.topology = super().run(tpu.initialize_system())
          assert self.topology is not None
      fetch_mapper = session._FetchMapper.for_fetch(fetches)
      new_fetches = []
      for fetch in fetch_mapper.unique_fetches():
          if isinstance(fetch, ops.Operation):
              fetch = tpu.rewrite(lambda fetch=fetch: fetch)
          new_fetches.append(fetch)
      rewritten_fetches = fetch_mapper.build_results(new_fetches)
      return super().run(
          rewritten_fetches, feed_dict, options, run_metadata
      )
  
imports: from collections.abc import Iterator
  import contextlib
  import os
  import random
  import re
  import numpy
  from tensorflow.core.framework import types_pb2
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.core.protobuf import rewriter_config_pb2
  from tensorflow.python.client import session
  from tensorflow.python.compiler.xla import jit
  from tensorflow.python.eager import context
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import random_seed
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import flags
  from tensorflow.python.platform import test
  from tensorflow.python.platform import tf_logging
label_desc: Use image node_id 2 for calling the TPURewriteSession obj's underlying member method code with example usage: obj.run(fetches, feed_dict, options, run_metadata) and returns: super