class_docstr: AWS Inferentia and Trainium accelerators.
class_docstr_tok: ["AWS","Inferentia","and","Trainium","accelerators","."]
docstr: Attempt to detect the number of Neuron cores on this machine.
  
  Returns:
      The number of Neuron cores if any were detected, otherwise 0.
docstr_tok: ["Attempt","to","detect","the","number","of","Neuron","cores","on","this","machine",".","Returns",":","The","number","of","Neuron","cores","if","any","were","detected",",","otherwise","0","."]
code: def get_current_node_num_accelerators() -> int:
      """
      Attempt to detect the number of Neuron cores on this machine.
  
      Returns:
          The number of Neuron cores if any were detected, otherwise 0.
      """
      nc_count: int = 0
      neuron_path = "/opt/aws/neuron/bin/"
      if sys.platform.startswith("linux") and os.path.isdir(
          neuron_path
      ):
          result = subprocess.run(
              [os.path.join(neuron_path, "neuron-ls"), "--json-output"],
              stdout=subprocess.PIPE,
              stderr=subprocess.PIPE,
          )
          if result.returncode == 0 and result.stdout:
              neuron_devices = json.loads(result.stdout)
              for neuron_device in neuron_devices:
                  nc_count += neuron_device.get("nc_count", 0)
      return nc_count
  
file_path: ray/python/ray/_private/accelerators/neuron.py
imports: import os
  import sys
  import json
  import logging
  import subprocess
  from typing import Optional, List, Tuple
  from ray._private.accelerators.accelerator import AcceleratorManager
label_desc: Use image node_id 4 for calling the NeuronAcceleratorManager obj's underlying member method code with example usage: obj.get_current_node_num_accelerators() and returns: nc_count