code: def test_weapon_auto_switch(self):
      env = deepmind_lab.Lab(
          "tests/update_inventory_test",
          ["DEBUG.AMOUNT", "DEBUG.GADGET"],
          config={"fps": "60", "width": "80", "height": "80"},
      )
  
      action_spec = env.action_spec()
      action_index = {
          action["name"]: i for i, action in enumerate(action_spec)
      }
  
      action = np.zeros([len(action_spec)], dtype=np.intc)
  
      action[action_index["FIRE"]] = 1
  
      env.reset()
  
      self.assertEqual(
          env.observations()["DEBUG.GADGET"][0], GADGETS["ORB"]
      )
      self.assertEqual(env.observations()["DEBUG.AMOUNT"][0], 2)
  
      ## Fire two orbs.
      for _ in six.moves.range(600):
          env.step(action, 1)
          self.assertEqual(
              env.observations()["DEBUG.GADGET"][0], GADGETS["ORB"]
          )
          if env.observations()["DEBUG.AMOUNT"][0] == 0:
              break
      else:
          self.fail("Failed use orbs!")
  
      ## Wait for weapon switch.
      for _ in six.moves.range(600):
          env.step(action, 1)
          if env.observations()["DEBUG.GADGET"][0] == GADGETS["RAPID"]:
              break
      else:
          self.fail("Failed to auto switch weapon!")
  
      self.assertEqual(env.observations()["DEBUG.AMOUNT"][0], 10)
      for _ in six.moves.range(600):
          env.step(action, 1)
          if env.observations()["DEBUG.AMOUNT"][0] == 0:
              break
      else:
          self.fail("Failed to use rapid!")
  
file_path: lab/python/tests/update_inventory_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  from absl.testing import absltest
  import numpy
  import six
  import deepmind_lab
label_desc: Use image node_id 1 for calling the UpdateInventoryTest obj's underlying member method code with example usage: obj.test_weapon_auto_switch() without return types