code: def _tpu_replicator_or_skip_test() -> snt_replicator.TpuReplicator:
      tpus = tf.config.experimental.list_logical_devices(
          device_type="TPU"
      )
      if not tpus:
          raise unittest.SkipTest("No TPU available.")
  
      logging.info(
          "Using TpuReplicator over %s", [t.name for t in tpus]
      )
      return snt_replicator.TpuReplicator()
  
imports: from typing import Callable, Sequence, Tuple
  import unittest
  from absl import logging
  from sonnet.src.distribute import replicator
  import tensorflow
label_desc: Use image node_id 2 for calling a global function with example usage: _tpu_replicator_or_skip_test() and returns: snt_replicator