code: def act(self, *, states, auxiliaries, parallel):
      batch_size = tf_util.cast(
          x=tf.shape(input=parallel)[0], dtype="int"
      )
  
      # Input assertions
      assertions = list()
      if self.config.create_tf_assertions:
          assertions.extend(
              self.states_spec.tf_assert(
                  x=states,
                  batch_size=batch_size,
                  message="Agent.act: invalid {issue} for {name} state input.",
              )
          )
          assertions.extend(
              self.auxiliaries_spec.tf_assert(
                  x=auxiliaries,
                  batch_size=batch_size,
                  message="Agent.act: invalid {issue} for {name} input.",
              )
          )
          assertions.extend(
              self.parallel_spec.tf_assert(
                  x=parallel,
                  batch_size=batch_size,
                  message="Agent.act: invalid {issue} for parallel input.",
              )
          )
          # Mask assertions
          if self.config.enable_int_action_masking:
              true = tf_util.constant(value=True, dtype="bool")
              for name, spec in self.actions_spec.items():
                  if spec.type == "int":
                      assertions.append(
                          tf.debugging.assert_equal(
                              x=tf.reduce_all(
                                  input_tensor=tf.math.reduce_any(
                                      input_tensor=auxiliaries[name][
                                          "mask"
                                      ],
                                      axis=(spec.rank + 1),
                                  )
                              ),
                              y=true,
                              message="Agent.independent_act: at least one action has to be valid.",
                          )
                      )
  
      with tf.control_dependencies(control_inputs=assertions):
          # Retrieve internals
          internals = self.previous_internals.fmap(
              function=(
                  lambda x: tf.gather(params=x, indices=parallel)
              ),
              cls=TensorDict,
          )
  
          # Core act
          deterministic = tf_util.constant(value=False, dtype="bool")
          actions, internals = self.core_act(
              states=states,
              internals=internals,
              auxiliaries=auxiliaries,
              parallel=parallel,
              deterministic=deterministic,
              independent=False,
          )
  
      # Action assertions
      assertions = list()
      if self.config.create_tf_assertions:
          assertions.extend(
              self.actions_spec.tf_assert(
                  x=actions, batch_size=batch_size
              )
          )
          if self.config.enable_int_action_masking:
              for name, spec, action in self.actions_spec.zip_items(
                  actions
              ):
                  if spec.type == "int":
                      is_valid = tf.reduce_all(
                          input_tensor=tf.gather(
                              params=auxiliaries[name]["mask"],
                              indices=tf.expand_dims(
                                  input=action, axis=(spec.rank + 1)
                              ),
                              batch_dims=(spec.rank + 1),
                          )
                      )
                      assertions.append(
                          tf.debugging.assert_equal(
                              x=is_valid,
                              y=true,
                              message="Action mask check.",
                          )
                      )
  
      # Remember internals
      dependencies = list()
      indices = tf.expand_dims(input=parallel, axis=1)
      for name, previous, internal in self.previous_internals.zip_items(
          internals
      ):
          value = tf.tensor_scatter_nd_update(
              tensor=previous, indices=indices, updates=internal
          )
          dependencies.append(previous.assign(value=value))
          # sparse_delta = tf.IndexedSlices(values=internal, indices=parallel)
          # dependencies.append(previous.scatter_update(sparse_delta=sparse_delta))
  
      # Increment timestep (after core act)
      with tf.control_dependencies(
          control_inputs=(actions.flatten() + internals.flatten())
      ):
          dependencies.append(
              self.timesteps.assign_add(
                  delta=batch_size, read_value=False
              )
          )
  
      with tf.control_dependencies(
          control_inputs=(dependencies + assertions)
      ):
          actions = actions.fmap(function=tf_util.identity)
          timestep = tf_util.identity(input=self.timesteps)
          return actions, timestep
  
imports: from collections import OrderedDict
  import logging
  import os
  import time
  import h5py
  import numpy
  import tensorflow
  from tensorforce import TensorforceError
  from tensorforce.core import ArrayDict, Module, SignatureDict, TensorDict, TensorSpec, TensorsSpec, tf_function, tf_util, VariableDict
  from tensorforce.core.layers import Layer
label_desc: Use image node_id 17 for calling the Model obj's underlying member method code with example usage: obj.act() and returns: actions,  timestep