class_docstr: Example of weight sharing between two different TorchModelV2s.
  
  The shared (single) layer is simply defined outside of the two Models,
  then used by both Models in their forward pass.
class_docstr_tok: ["Example","of","weight","sharing","between","two","different","TorchModelV2s",".","The","shared","(","single",")","layer","is","simply","defined","outside","of","the","two","Models",",","then","used","by","both","Models","in","their","forward","pass","."]
code: def __init__(
      self,
      observation_space,
      action_space,
      num_outputs,
      model_config,
      name,
  ):
      TorchModelV2.__init__(
          self,
          observation_space,
          action_space,
          num_outputs,
          model_config,
          name,
      )
      nn.Module.__init__(self)
  
      # Non-shared initial layer.
      self.first_layer = SlimFC(
          int(np.product(observation_space.shape)),
          64,
          activation_fn=nn.ReLU,
          initializer=torch.nn.init.xavier_uniform_,
      )
  
      # Non-shared final layer.
      self.last_layer = SlimFC(
          64,
          self.num_outputs,
          activation_fn=None,
          initializer=torch.nn.init.xavier_uniform_,
      )
      self.vf = SlimFC(
          64,
          1,
          activation_fn=None,
          initializer=torch.nn.init.xavier_uniform_,
      )
      self._global_shared_layer = TORCH_GLOBAL_SHARED_LAYER
      self._output = None
  
imports: import numpy
  from ray.rllib.models.modelv2 import ModelV2
  from ray.rllib.models.tf.tf_modelv2 import TFModelV2
  from ray.rllib.models.torch.misc import SlimFC
  from ray.rllib.models.torch.torch_modelv2 import TorchModelV2
  from ray.rllib.utils.annotations import override
  from ray.rllib.utils.framework import try_import_tf, try_import_torch
label_desc: Use image node_id 1 to create a new TorchSharedWeightsModel object from inherited base classes: TorchModelV2, nn with example: obj = TorchSharedWeightsModel(observation_space, action_space, num_outputs, model_config, name)