class_docstr: Ascend NPU accelerators.
docstr: Attempt to detect the number of NPUs on this machine.
  
  NPU chips are represented as devices within `/dev/`, either as `/dev/davinci?`.
  
  Returns:
      The number of NPUs if any were detected, otherwise 0.
docstr_tok: ["Attempt","to","detect","the","number","of","NPUs","on","this","machine",".","NPU","chips","are","represented","as","devices","within","`","\/dev\/","`",",","either","as","`","\/dev\/davinci","?","`",".","Returns",":","The","number","of","NPUs","if","any","were","detected",",","otherwise","0","."]
code: def get_current_node_num_accelerators() -> int:
      """Attempt to detect the number of NPUs on this machine.
  
      NPU chips are represented as devices within `/dev/`, either as `/dev/davinci?`.
  
      Returns:
          The number of NPUs if any were detected, otherwise 0.
      """
      try:
          import acl
  
          device_count, ret = acl.rt.get_device_count()
          if ret == 0:
              return device_count
      except Exception as e:
          logger.debug("Could not import AscendCL: %s", e)
  
      try:
          npu_files = glob.glob("/dev/davinci?")
          return len(npu_files)
      except Exception as e:
          logger.debug("Failed to detect number of NPUs: %s", e)
      return 0
  
file_path: ray/python/ray/_private/accelerators/npu.py
imports: import os
  import glob
  import logging
  from typing import Optional, List, Tuple
  from ray._private.accelerators.accelerator import AcceleratorManager
label_desc: Use image node_id 4 for calling the NPUAcceleratorManager obj's underlying member method code with example usage: obj.get_current_node_num_accelerators() and returns: int, len, device_count