docstr: Override forward() so that number of outputs can be automatically set
docstr_tok: ["Override","forward","(",")","so","that","number","of","outputs","can","be","automatically","set"]
code: def forward(self, *args):
      """
      Override forward() so that number of outputs can be automatically set
      """
      outputs = super(Head, self).forward(*args)
      if isinstance(outputs, tuple):
          num_outputs = len(outputs)
      else:
          assert isinstance(outputs, NDArray) or isinstance(
              outputs, Symbol
          )
          num_outputs = 1
      if self._num_outputs is None:
          self._num_outputs = num_outputs
      else:
          assert (
              self._num_outputs == num_outputs
          ), "Number of outputs cannot change ({} != {})".format(
              self._num_outputs, num_outputs
          )
      assert self._num_outputs == len(
          self.loss().input_schema.head_outputs
      )
      return outputs
  
imports: from typing import Dict, List, Union, Tuple
  import mxnet
  from mxnet.initializer import Initializer, register
  from mxnet.gluon import nn, loss
  from mxnet.ndarray import NDArray
  from mxnet.symbol import Symbol
  from rl_coach.base_parameters import AgentParameters
  from rl_coach.spaces import SpacesDefinition
label_desc: Use image node_id 4 for calling the Head obj's underlying member method code with example usage: obj.forward() and returns: outputs