# Subclasses of TorchModelV2 must also inherit from nn.Module, e.g., MyModel(TorchModelV2, nn.Module)

**URL:** <https://discuss.ray.io/t/subclasses-of-torchmodelv2-must-also-inherit-from-nn-module-e-g-mymodel-torchmodelv2-nn-module/5778>\
**Category:** RLlib\
**Created:** [April 13, 2022, 4:57pm UTC](https://discuss.ray.io/t/subclasses-of-torchmodelv2-must-also-inherit-from-nn-module-e-g-mymodel-torchmodelv2-nn-module/5778 "2022-04-13T16:57:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ph459](https://avatars.discourse-cdn.com/v4/letter/p/d6d6ee/32.png) [@ph459](https://discuss.ray.io/u/ph459)\
**Post date:** [April 13, 2022, 4:57pm UTC](https://discuss.ray.io/t/subclasses-of-torchmodelv2-must-also-inherit-from-nn-module-e-g-mymodel-torchmodelv2-nn-module/5778/1 "2022-04-13T16:57:06Z")

</div>

Utilizing this example: [ray/custom\_env.py at master · ray-project/ray · GitHub](https://github.com/ray-project/ray/blob/master/rllib/examples/custom_env.py)

I get the following error when using Pytorch.

```auto
Subclasses of TorchModelV2 must also inherit from nn.Module, e.g., MyModel(TorchModelV2, nn.Module)

```

Is there any guidance on the best approach to fix this API change?

---

<div class="post-metadata">

**Author:** ![arturn](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/arturn/32/2096_2.png) [@arturn](https://discuss.ray.io/u/arturn)\
**Post date:** [April 15, 2022, 4:22pm UTC](https://discuss.ray.io/t/subclasses-of-torchmodelv2-must-also-inherit-from-nn-module-e-g-mymodel-torchmodelv2-nn-module/5778/2 "2022-04-15T16:22:40Z")

</div>

Could not reproduce this on current master.  
The script runs fine there.  
That’s what you are trying to do, right? Simply run the script?
