code: def _get_num_tpu_chips(node: dict) -> int:
      chips = 0
      if "acceleratorType" in node:
          accelerator_type = node["acceleratorType"]
          # `acceleratorType` is typically v{generation}-{cores}
          cores = int(accelerator_type.split("-")[1])
          chips = cores / tpu.TPU_CORES_PER_CHIP
      if "acceleratorConfig" in node:
          topology = node["acceleratorConfig"]["topology"]
          # `topology` is typically {chips}x{chips}x{chips}
          # Multiply all dimensions together to get total number of chips
          chips = 1
          for dim in topology.split("x"):
              chips *= int(dim)
      return chips
  
imports: import copy
  import json
  import logging
  import os
  import re
  import time
  from functools import partial, reduce
  from cryptography.hazmat.backends import default_backend
  from cryptography.hazmat.primitives import serialization
  from cryptography.hazmat.primitives.asymmetric import rsa
  from google.oauth2 import service_account
  from google.oauth2.credentials import Credentials
  from googleapiclient import discovery, errors
  from ray._private.accelerators import TPUAcceleratorManager, tpu
  from ray.autoscaler._private.gcp.node import MAX_POLLS, POLL_INTERVAL, GCPNodeType
  from ray.autoscaler._private.util import check_legacy_fields
label_desc: Use image node_id 3 for calling a global function with example usage: _get_num_tpu_chips(node) and returns: chips