# What is @staticmethod?

**URL:** <https://discuss.pytorch.org/t/what-is-staticmethod/66519>\
**Category:** Uncategorized\
**Created:** [January 13, 2020, 1:20pm UTC](https://discuss.pytorch.org/t/what-is-staticmethod/66519 "2020-01-13T13:20:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![f3ba](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/f/4491bb/32.png) [@f3ba](https://discuss.pytorch.org/u/f3ba)\
**Post date:** [January 13, 2020, 1:20pm UTC](https://discuss.pytorch.org/t/what-is-staticmethod/66519/1 "2020-01-13T13:20:02Z")

</div>

In the docs it is recommended that when implementing `forward` and `backward` passes for a custom function, they be marked as `@staticmethod`. For example: [https://pytorch.org/docs/stable/notes/extending.html](https://pytorch.org/docs/stable/notes/extending.html).

What does the annotation `@staticmethod` do? I can’t find an explanation in the docs.

---

<div class="post-metadata">

**Author:** ![tom](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tom/32/3162_2.png) [@tom](https://discuss.pytorch.org/u/tom)\
**Post date:** [January 13, 2020, 1:51pm UTC](https://discuss.pytorch.org/t/what-is-staticmethod/66519/2 "2020-01-13T13:51:21Z")

</div>

Static methods are methods not attached to a particular instance - so they do take a `self` as first argument. They’re not PyTorch-specific but a general Python thing:  
[https://docs.python.org/3.5/library/functions.html#staticmethod](https://docs.python.org/3.5/library/functions.html#staticmethod)

PyTorch’s autograd Functions store state in a special context object (passed as the first argument) rather than the Function object, that is why they’re static. (In ancient times before PyTorch 0.2 this used to be different.)

Best regards

Thomas
