We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
torch.nn.InstanceNorm1d has inconsistent semantics of train and eval
For `torch.nn.InstanceNorm1d` the docs say:

*At evaluation time (.eval()), the default behaviour of the InstanceNorm module stays the same i.e. running mean/variance is NOT used for normalization. One can force using stored mean and variance with .train(False) method.*

However, the source for `.eval()` shows that it simply calls `.train(False)`.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `torch/nn/modules/instancenorm.py`
Content:
```
1 from .batchnorm import _BatchNorm
2 from .. import functional as F
3 
4 
5 class _InstanceNorm(_BatchNorm):
6     def __init__(self, num_features, eps=1e-5, momentum=0.1, affine=False):
7         super(_InstanceNorm, self).__init__(
8             num_features, eps, momentum, affine)
9 
10     def forward(self, input):
11         b, c = input.size(0), input.size(1)
12 
13         # Repeat stored stats and affine transform params
14         running_mean = self.running_mean.repeat(b)
15         running_var = self.running_var.repeat(b)
16 
17         weight, bias = None, None
18         if self.affine:
19             weight = self.weight.repeat(b)
20             bias = self.bias.repeat(b)
21 
22         # Apply instance norm
23         input_reshaped = input.contiguous().view(1, b * c, *input.size()[2:])
24 
25         out = F.batch_norm(
26             input_reshaped, running_mean, running_var, weight, bias,
27             True, self.momentum, self.eps)
28 
29         # Reshape back
30         self.running_mean.copy_(running_mean.view(b, c).mean(0, keepdim=False))
31         self.running_var.copy_(running_var.view(b, c).mean(0, keepdim=False))
32 
33         return out.view(b, c, *input.size()[2:])
34 
35     def eval(self):
36         return self
37 
38 
39 class InstanceNorm1d(_InstanceNorm):
40     r"""Applies Instance Normalization over a 3d input that is seen as a mini-batch.
41 
42     .. math::
43 
44         y = \frac{x - mean[x]}{ \sqrt{Var[x]} + \epsilon} * gamma + beta
45 
46     The mean and standard-deviation are calculated per-dimension separately
47     for each object in a mini-batch. Gamma and beta are learnable parameter vectors
48     of size C (where C is the input size).
49 
50     During training, this layer keeps a running estimate of its computed mean
51     and variance. The running sum is kept with a default momentum of 0.1.
52 
53     At evaluation time (`.eval()`), the default behaviour of the InstanceNorm module stays the same
54     i.e. running mean/variance is NOT used for normalization. One can force using stored
55     mean and variance with `.train(False)` method.
56 
57     Args:
58         num_features: num_features from an expected input of size `batch_size x num_features x width`
59         eps: a value added to the denominator for numerical stability. Default: 1e-5
60         momentum: the value used for the running_mean and running_var computation. Default: 0.1
61         affine: a boolean value that when set to ``True``, gives the layer learnable
62             affine parameters. Default: ``False``
63 
64     Shape:
65         - Input: :math:`(N, C, L)`
66         - Output: :math:`(N, C, L)` (same shape as input)
67 
68     Examples:
69         >>> # Without Learnable Parameters
70         >>> m = nn.InstanceNorm1d(100)
71         >>> # With Learnable Parameters
72         >>> m = nn.InstanceNorm1d(100, affine=True)
73         >>> input = autograd.Variable(torch.randn(20, 100, 40))
74         >>> output = m(input)
75     """
76 
77     def _check_input_dim(self, input):
78         if input.dim() != 3:
79             raise ValueError('expected 3D input (got {}D input)'
80                              .format(input.dim()))
81         super(InstanceNorm1d, self)._check_input_dim(input)
82 
83 
84 class InstanceNorm2d(_InstanceNorm):
85     r"""Applies Instance Normalization over a 4d input that is seen as a mini-batch of 3d inputs
86 
87     .. math::
88 
89         y = \frac{x - mean[x]}{ \sqrt{Var[x]} + \epsilon} * gamma + beta
90 
91     The mean and standard-deviation are calculated per-dimension separately
92     for each object in a mini-batch. Gamma and beta are learnable parameter vectors
93     of size C (where C is the input size).
94 
95     During training, this layer keeps a running estimate of its computed mean
96     and variance. The running sum is kept with a default momentum of 0.1.
97 
98     At evaluation time (`.eval()`), the default behaviour of the InstanceNorm module stays the same
99     i.e. running mean/variance is NOT used for normalization. One can force using stored
100     mean and variance with `.train(False)` method.
101 
102     Args:
103         num_features: num_features from an expected input of size batch_size x num_features x height x width
104         eps: a value added to the denominator for numerical stability. Default: 1e-5
105         momentum: the value used for the running_mean and running_var computation. Default: 0.1
106         affine: a boolean value that when set to ``True``, gives the layer learnable
107             affine parameters. Default: ``False``
108 
109     Shape:
110         - Input: :math:`(N, C, H, W)`
111         - Output: :math:`(N, C, H, W)` (same shape as input)
112 
113     Examples:
114         >>> # Without Learnable Parameters
115         >>> m = nn.InstanceNorm2d(100)
116         >>> # With Learnable Parameters
117         >>> m = nn.InstanceNorm2d(100, affine=True)
118         >>> input = autograd.Variable(torch.randn(20, 100, 35, 45))
119         >>> output = m(input)
120     """
121 
122     def _check_input_dim(self, input):
123         if input.dim() != 4:
124             raise ValueError('expected 4D input (got {}D input)'
125                              .format(input.dim()))
126         super(InstanceNorm2d, self)._check_input_dim(input)
127 
128 
129 class InstanceNorm3d(_InstanceNorm):
130     r"""Applies Instance Normalization over a 5d input that is seen as a mini-batch of 4d inputs
131 
132     .. math::
133 
134         y = \frac{x - mean[x]}{ \sqrt{Var[x]} + \epsilon} * gamma + beta
135 
136     The mean and standard-deviation are calculated per-dimension separately for each object in a mini-batch.
137     Gamma and beta are learnable parameter vectors
138     of size C (where C is the input size).
139 
140     During training, this layer keeps a running estimate of its computed mean
141     and variance. The running sum is kept with a default momentum of 0.1.
142 
143     At evaluation time (`.eval()`), the default behaviour of the InstanceNorm module stays the same
144     i.e. running mean/variance is NOT used for normalization. One can force using stored
145     mean and variance with `.train(False)` method.
146 
147 
148     Args:
149         num_features: num_features from an expected input of size batch_size x num_features x depth x height x width
150         eps: a value added to the denominator for numerical stability. Default: 1e-5
151         momentum: the value used for the running_mean and running_var computation. Default: 0.1
152         affine: a boolean value that when set to ``True``, gives the layer learnable
153             affine parameters. Default: ``False``
154 
155     Shape:
156         - Input: :math:`(N, C, D, H, W)`
157         - Output: :math:`(N, C, D, H, W)` (same shape as input)
158 
159     Examples:
160         >>> # Without Learnable Parameters
161         >>> m = nn.InstanceNorm3d(100)
162         >>> # With Learnable Parameters
163         >>> m = nn.InstanceNorm3d(100, affine=True)
164         >>> input = autograd.Variable(torch.randn(20, 100, 35, 45, 10))
165         >>> output = m(input)
166     """
167 
168     def _check_input_dim(self, input):
169         if input.dim() != 5:
170             raise ValueError('expected 5D input (got {}D input)'
171                              .format(input.dim()))
172         super(InstanceNorm3d, self)._check_input_dim(input)
173
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/torch/nn/modules/instancenorm.py b/torch/nn/modules/instancenorm.py
--- a/torch/nn/modules/instancenorm.py
+++ b/torch/nn/modules/instancenorm.py
@@ -6,6 +6,7 @@
     def __init__(self, num_features, eps=1e-5, momentum=0.1, affine=False):
         super(_InstanceNorm, self).__init__(
             num_features, eps, momentum, affine)
+        self.use_running_stats = False
 
     def forward(self, input):
         b, c = input.size(0), input.size(1)
@@ -24,7 +25,7 @@
 
         out = F.batch_norm(
             input_reshaped, running_mean, running_var, weight, bias,
-            True, self.momentum, self.eps)
+            not self.use_running_stats, self.momentum, self.eps)
 
         # Reshape back
         self.running_mean.copy_(running_mean.view(b, c).mean(0, keepdim=False))
@@ -32,8 +33,14 @@
 
         return out.view(b, c, *input.size()[2:])
 
-    def eval(self):
-        return self
+    def use_running_stats(self, mode=True):
+        r"""Set using running statistics or instance statistics.
+
+        Instance normalization usually use instance statistics in both training
+        and evaluation modes. But users can set this method to use running
+        statistics in the fashion similar to batch normalization in eval mode.
+        """
+        self.use_running_stats = mode
 
 
 class InstanceNorm1d(_InstanceNorm):
@@ -52,7 +59,8 @@
 
     At evaluation time (`.eval()`), the default behaviour of the InstanceNorm module stays the same
     i.e. running mean/variance is NOT used for normalization. One can force using stored
-    mean and variance with `.train(False)` method.
+    mean and variance with `.use_running_stats(mode=True)` method, and switch back to normal
+    behavior with `.use_running_stats(mode=False)` method.
 
     Args:
         num_features: num_features from an expected input of size `batch_size x num_features x width`
@@ -97,7 +105,8 @@
 
     At evaluation time (`.eval()`), the default behaviour of the InstanceNorm module stays the same
     i.e. running mean/variance is NOT used for normalization. One can force using stored
-    mean and variance with `.train(False)` method.
+    mean and variance with `.use_running_stats(mode=True)` method, and switch back to normal
+    behavior with `.use_running_stats(mode=False)` method.
 
     Args:
         num_features: num_features from an expected input of size batch_size x num_features x height x width
@@ -142,7 +151,8 @@
 
     At evaluation time (`.eval()`), the default behaviour of the InstanceNorm module stays the same
     i.e. running mean/variance is NOT used for normalization. One can force using stored
-    mean and variance with `.train(False)` method.
+    mean and variance with `.use_running_stats(mode=True)` method, and switch back to normal
+    behavior with `.use_running_stats(mode=False)` method.
 
 
     Args:

{"golden_diff": "diff --git a/torch/nn/modules/instancenorm.py b/torch/nn/modules/instancenorm.py\n--- a/torch/nn/modules/instancenorm.py\n+++ b/torch/nn/modules/instancenorm.py\n@@ -6,6 +6,7 @@\n     def __init__(self, num_features, eps=1e-5, momentum=0.1, affine=False):\n         super(_InstanceNorm, self).__init__(\n             num_features, eps, momentum, affine)\n+        self.use_running_stats = False\n \n     def forward(self, input):\n         b, c = input.size(0), input.size(1)\n@@ -24,7 +25,7 @@\n \n         out = F.batch_norm(\n             input_reshaped, running_mean, running_var, weight, bias,\n-            True, self.momentum, self.eps)\n+            not self.use_running_stats, self.momentum, self.eps)\n \n         # Reshape back\n         self.running_mean.copy_(running_mean.view(b, c).mean(0, keepdim=False))\n@@ -32,8 +33,14 @@\n \n         return out.view(b, c, *input.size()[2:])\n \n-    def eval(self):\n-        return self\n+    def use_running_stats(self, mode=True):\n+        r\"\"\"Set using running statistics or instance statistics.\n+\n+        Instance normalization usually use instance statistics in both training\n+        and evaluation modes. But users can set this method to use running\n+        statistics in the fashion similar to batch normalization in eval mode.\n+        \"\"\"\n+        self.use_running_stats = mode\n \n \n class InstanceNorm1d(_InstanceNorm):\n@@ -52,7 +59,8 @@\n \n     At evaluation time (`.eval()`), the default behaviour of the InstanceNorm module stays the same\n     i.e. running mean/variance is NOT used for normalization. One can force using stored\n-    mean and variance with `.train(False)` method.\n+    mean and variance with `.use_running_stats(mode=True)` method, and switch back to normal\n+    behavior with `.use_running_stats(mode=False)` method.\n \n     Args:\n         num_features: num_features from an expected input of size `batch_size x num_features x width`\n@@ -97,7 +105,8 @@\n \n     At evaluation time (`.eval()`), the default behaviour of the InstanceNorm module stays the same\n     i.e. running mean/variance is NOT used for normalization. One can force using stored\n-    mean and variance with `.train(False)` method.\n+    mean and variance with `.use_running_stats(mode=True)` method, and switch back to normal\n+    behavior with `.use_running_stats(mode=False)` method.\n \n     Args:\n         num_features: num_features from an expected input of size batch_size x num_features x height x width\n@@ -142,7 +151,8 @@\n \n     At evaluation time (`.eval()`), the default behaviour of the InstanceNorm module stays the same\n     i.e. running mean/variance is NOT used for normalization. One can force using stored\n-    mean and variance with `.train(False)` method.\n+    mean and variance with `.use_running_stats(mode=True)` method, and switch back to normal\n+    behavior with `.use_running_stats(mode=False)` method.\n \n \n     Args:\n", "issue": "torch.nn.InstanceNorm1d has inconsistent semantics of train and eval\nFor `torch.nn.InstanceNorm1d` the docs say:\r\n\r\n*At evaluation time (.eval()), the default behaviour of the InstanceNorm module stays the same i.e. running mean/variance is NOT used for normalization. One can force using stored mean and variance with .train(False) method.*\r\n\r\nHowever, the source for `.eval()` shows that it simply calls `.train(False)`.\n", "before_files": [{"content": "from .batchnorm import _BatchNorm\nfrom .. import functional as F\n\n\nclass _InstanceNorm(_BatchNorm):\n    def __init__(self, num_features, eps=1e-5, momentum=0.1, affine=False):\n        super(_InstanceNorm, self).__init__(\n            num_features, eps, momentum, affine)\n\n    def forward(self, input):\n        b, c = input.size(0), input.size(1)\n\n        # Repeat stored stats and affine transform params\n        running_mean = self.running_mean.repeat(b)\n        running_var = self.running_var.repeat(b)\n\n        weight, bias = None, None\n        if self.affine:\n            weight = self.weight.repeat(b)\n            bias = self.bias.repeat(b)\n\n        # Apply instance norm\n        input_reshaped = input.contiguous().view(1, b * c, *input.size()[2:])\n\n        out = F.batch_norm(\n            input_reshaped, running_mean, running_var, weight, bias,\n            True, self.momentum, self.eps)\n\n        # Reshape back\n        self.running_mean.copy_(running_mean.view(b, c).mean(0, keepdim=False))\n        self.running_var.copy_(running_var.view(b, c).mean(0, keepdim=False))\n\n        return out.view(b, c, *input.size()[2:])\n\n    def eval(self):\n        return self\n\n\nclass InstanceNorm1d(_InstanceNorm):\n    r\"\"\"Applies Instance Normalization over a 3d input that is seen as a mini-batch.\n\n    .. math::\n\n        y = \\frac{x - mean[x]}{ \\sqrt{Var[x]} + \\epsilon} * gamma + beta\n\n    The mean and standard-deviation are calculated per-dimension separately\n    for each object in a mini-batch. Gamma and beta are learnable parameter vectors\n    of size C (where C is the input size).\n\n    During training, this layer keeps a running estimate of its computed mean\n    and variance. The running sum is kept with a default momentum of 0.1.\n\n    At evaluation time (`.eval()`), the default behaviour of the InstanceNorm module stays the same\n    i.e. running mean/variance is NOT used for normalization. One can force using stored\n    mean and variance with `.train(False)` method.\n\n    Args:\n        num_features: num_features from an expected input of size `batch_size x num_features x width`\n        eps: a value added to the denominator for numerical stability. Default: 1e-5\n        momentum: the value used for the running_mean and running_var computation. Default: 0.1\n        affine: a boolean value that when set to ``True``, gives the layer learnable\n            affine parameters. Default: ``False``\n\n    Shape:\n        - Input: :math:`(N, C, L)`\n        - Output: :math:`(N, C, L)` (same shape as input)\n\n    Examples:\n        >>> # Without Learnable Parameters\n        >>> m = nn.InstanceNorm1d(100)\n        >>> # With Learnable Parameters\n        >>> m = nn.InstanceNorm1d(100, affine=True)\n        >>> input = autograd.Variable(torch.randn(20, 100, 40))\n        >>> output = m(input)\n    \"\"\"\n\n    def _check_input_dim(self, input):\n        if input.dim() != 3:\n            raise ValueError('expected 3D input (got {}D input)'\n                             .format(input.dim()))\n        super(InstanceNorm1d, self)._check_input_dim(input)\n\n\nclass InstanceNorm2d(_InstanceNorm):\n    r\"\"\"Applies Instance Normalization over a 4d input that is seen as a mini-batch of 3d inputs\n\n    .. math::\n\n        y = \\frac{x - mean[x]}{ \\sqrt{Var[x]} + \\epsilon} * gamma + beta\n\n    The mean and standard-deviation are calculated per-dimension separately\n    for each object in a mini-batch. Gamma and beta are learnable parameter vectors\n    of size C (where C is the input size).\n\n    During training, this layer keeps a running estimate of its computed mean\n    and variance. The running sum is kept with a default momentum of 0.1.\n\n    At evaluation time (`.eval()`), the default behaviour of the InstanceNorm module stays the same\n    i.e. running mean/variance is NOT used for normalization. One can force using stored\n    mean and variance with `.train(False)` method.\n\n    Args:\n        num_features: num_features from an expected input of size batch_size x num_features x height x width\n        eps: a value added to the denominator for numerical stability. Default: 1e-5\n        momentum: the value used for the running_mean and running_var computation. Default: 0.1\n        affine: a boolean value that when set to ``True``, gives the layer learnable\n            affine parameters. Default: ``False``\n\n    Shape:\n        - Input: :math:`(N, C, H, W)`\n        - Output: :math:`(N, C, H, W)` (same shape as input)\n\n    Examples:\n        >>> # Without Learnable Parameters\n        >>> m = nn.InstanceNorm2d(100)\n        >>> # With Learnable Parameters\n        >>> m = nn.InstanceNorm2d(100, affine=True)\n        >>> input = autograd.Variable(torch.randn(20, 100, 35, 45))\n        >>> output = m(input)\n    \"\"\"\n\n    def _check_input_dim(self, input):\n        if input.dim() != 4:\n            raise ValueError('expected 4D input (got {}D input)'\n                             .format(input.dim()))\n        super(InstanceNorm2d, self)._check_input_dim(input)\n\n\nclass InstanceNorm3d(_InstanceNorm):\n    r\"\"\"Applies Instance Normalization over a 5d input that is seen as a mini-batch of 4d inputs\n\n    .. math::\n\n        y = \\frac{x - mean[x]}{ \\sqrt{Var[x]} + \\epsilon} * gamma + beta\n\n    The mean and standard-deviation are calculated per-dimension separately for each object in a mini-batch.\n    Gamma and beta are learnable parameter vectors\n    of size C (where C is the input size).\n\n    During training, this layer keeps a running estimate of its computed mean\n    and variance. The running sum is kept with a default momentum of 0.1.\n\n    At evaluation time (`.eval()`), the default behaviour of the InstanceNorm module stays the same\n    i.e. running mean/variance is NOT used for normalization. One can force using stored\n    mean and variance with `.train(False)` method.\n\n\n    Args:\n        num_features: num_features from an expected input of size batch_size x num_features x depth x height x width\n        eps: a value added to the denominator for numerical stability. Default: 1e-5\n        momentum: the value used for the running_mean and running_var computation. Default: 0.1\n        affine: a boolean value that when set to ``True``, gives the layer learnable\n            affine parameters. Default: ``False``\n\n    Shape:\n        - Input: :math:`(N, C, D, H, W)`\n        - Output: :math:`(N, C, D, H, W)` (same shape as input)\n\n    Examples:\n        >>> # Without Learnable Parameters\n        >>> m = nn.InstanceNorm3d(100)\n        >>> # With Learnable Parameters\n        >>> m = nn.InstanceNorm3d(100, affine=True)\n        >>> input = autograd.Variable(torch.randn(20, 100, 35, 45, 10))\n        >>> output = m(input)\n    \"\"\"\n\n    def _check_input_dim(self, input):\n        if input.dim() != 5:\n            raise ValueError('expected 5D input (got {}D input)'\n                             .format(input.dim()))\n        super(InstanceNorm3d, self)._check_input_dim(input)\n", "path": "torch/nn/modules/instancenorm.py"}], "after_files": [{"content": "from .batchnorm import _BatchNorm\nfrom .. import functional as F\n\n\nclass _InstanceNorm(_BatchNorm):\n    def __init__(self, num_features, eps=1e-5, momentum=0.1, affine=False):\n        super(_InstanceNorm, self).__init__(\n            num_features, eps, momentum, affine)\n        self.use_running_stats = False\n\n    def forward(self, input):\n        b, c = input.size(0), input.size(1)\n\n        # Repeat stored stats and affine transform params\n        running_mean = self.running_mean.repeat(b)\n        running_var = self.running_var.repeat(b)\n\n        weight, bias = None, None\n        if self.affine:\n            weight = self.weight.repeat(b)\n            bias = self.bias.repeat(b)\n\n        # Apply instance norm\n        input_reshaped = input.contiguous().view(1, b * c, *input.size()[2:])\n\n        out = F.batch_norm(\n            input_reshaped, running_mean, running_var, weight, bias,\n            not self.use_running_stats, self.momentum, self.eps)\n\n        # Reshape back\n        self.running_mean.copy_(running_mean.view(b, c).mean(0, keepdim=False))\n        self.running_var.copy_(running_var.view(b, c).mean(0, keepdim=False))\n\n        return out.view(b, c, *input.size()[2:])\n\n    def use_running_stats(self, mode=True):\n        r\"\"\"Set using running statistics or instance statistics.\n\n        Instance normalization usually use instance statistics in both training\n        and evaluation modes. But users can set this method to use running\n        statistics in the fashion similar to batch normalization in eval mode.\n        \"\"\"\n        self.use_running_stats = mode\n\n\nclass InstanceNorm1d(_InstanceNorm):\n    r\"\"\"Applies Instance Normalization over a 3d input that is seen as a mini-batch.\n\n    .. math::\n\n        y = \\frac{x - mean[x]}{ \\sqrt{Var[x]} + \\epsilon} * gamma + beta\n\n    The mean and standard-deviation are calculated per-dimension separately\n    for each object in a mini-batch. Gamma and beta are learnable parameter vectors\n    of size C (where C is the input size).\n\n    During training, this layer keeps a running estimate of its computed mean\n    and variance. The running sum is kept with a default momentum of 0.1.\n\n    At evaluation time (`.eval()`), the default behaviour of the InstanceNorm module stays the same\n    i.e. running mean/variance is NOT used for normalization. One can force using stored\n    mean and variance with `.use_running_stats(mode=True)` method, and switch back to normal\n    behavior with `.use_running_stats(mode=False)` method.\n\n    Args:\n        num_features: num_features from an expected input of size `batch_size x num_features x width`\n        eps: a value added to the denominator for numerical stability. Default: 1e-5\n        momentum: the value used for the running_mean and running_var computation. Default: 0.1\n        affine: a boolean value that when set to ``True``, gives the layer learnable\n            affine parameters. Default: ``False``\n\n    Shape:\n        - Input: :math:`(N, C, L)`\n        - Output: :math:`(N, C, L)` (same shape as input)\n\n    Examples:\n        >>> # Without Learnable Parameters\n        >>> m = nn.InstanceNorm1d(100)\n        >>> # With Learnable Parameters\n        >>> m = nn.InstanceNorm1d(100, affine=True)\n        >>> input = autograd.Variable(torch.randn(20, 100, 40))\n        >>> output = m(input)\n    \"\"\"\n\n    def _check_input_dim(self, input):\n        if input.dim() != 3:\n            raise ValueError('expected 3D input (got {}D input)'\n                             .format(input.dim()))\n        super(InstanceNorm1d, self)._check_input_dim(input)\n\n\nclass InstanceNorm2d(_InstanceNorm):\n    r\"\"\"Applies Instance Normalization over a 4d input that is seen as a mini-batch of 3d inputs\n\n    .. math::\n\n        y = \\frac{x - mean[x]}{ \\sqrt{Var[x]} + \\epsilon} * gamma + beta\n\n    The mean and standard-deviation are calculated per-dimension separately\n    for each object in a mini-batch. Gamma and beta are learnable parameter vectors\n    of size C (where C is the input size).\n\n    During training, this layer keeps a running estimate of its computed mean\n    and variance. The running sum is kept with a default momentum of 0.1.\n\n    At evaluation time (`.eval()`), the default behaviour of the InstanceNorm module stays the same\n    i.e. running mean/variance is NOT used for normalization. One can force using stored\n    mean and variance with `.use_running_stats(mode=True)` method, and switch back to normal\n    behavior with `.use_running_stats(mode=False)` method.\n\n    Args:\n        num_features: num_features from an expected input of size batch_size x num_features x height x width\n        eps: a value added to the denominator for numerical stability. Default: 1e-5\n        momentum: the value used for the running_mean and running_var computation. Default: 0.1\n        affine: a boolean value that when set to ``True``, gives the layer learnable\n            affine parameters. Default: ``False``\n\n    Shape:\n        - Input: :math:`(N, C, H, W)`\n        - Output: :math:`(N, C, H, W)` (same shape as input)\n\n    Examples:\n        >>> # Without Learnable Parameters\n        >>> m = nn.InstanceNorm2d(100)\n        >>> # With Learnable Parameters\n        >>> m = nn.InstanceNorm2d(100, affine=True)\n        >>> input = autograd.Variable(torch.randn(20, 100, 35, 45))\n        >>> output = m(input)\n    \"\"\"\n\n    def _check_input_dim(self, input):\n        if input.dim() != 4:\n            raise ValueError('expected 4D input (got {}D input)'\n                             .format(input.dim()))\n        super(InstanceNorm2d, self)._check_input_dim(input)\n\n\nclass InstanceNorm3d(_InstanceNorm):\n    r\"\"\"Applies Instance Normalization over a 5d input that is seen as a mini-batch of 4d inputs\n\n    .. math::\n\n        y = \\frac{x - mean[x]}{ \\sqrt{Var[x]} + \\epsilon} * gamma + beta\n\n    The mean and standard-deviation are calculated per-dimension separately for each object in a mini-batch.\n    Gamma and beta are learnable parameter vectors\n    of size C (where C is the input size).\n\n    During training, this layer keeps a running estimate of its computed mean\n    and variance. The running sum is kept with a default momentum of 0.1.\n\n    At evaluation time (`.eval()`), the default behaviour of the InstanceNorm module stays the same\n    i.e. running mean/variance is NOT used for normalization. One can force using stored\n    mean and variance with `.use_running_stats(mode=True)` method, and switch back to normal\n    behavior with `.use_running_stats(mode=False)` method.\n\n\n    Args:\n        num_features: num_features from an expected input of size batch_size x num_features x depth x height x width\n        eps: a value added to the denominator for numerical stability. Default: 1e-5\n        momentum: the value used for the running_mean and running_var computation. Default: 0.1\n        affine: a boolean value that when set to ``True``, gives the layer learnable\n            affine parameters. Default: ``False``\n\n    Shape:\n        - Input: :math:`(N, C, D, H, W)`\n        - Output: :math:`(N, C, D, H, W)` (same shape as input)\n\n    Examples:\n        >>> # Without Learnable Parameters\n        >>> m = nn.InstanceNorm3d(100)\n        >>> # With Learnable Parameters\n        >>> m = nn.InstanceNorm3d(100, affine=True)\n        >>> input = autograd.Variable(torch.randn(20, 100, 35, 45, 10))\n        >>> output = m(input)\n    \"\"\"\n\n    def _check_input_dim(self, input):\n        if input.dim() != 5:\n            raise ValueError('expected 5D input (got {}D input)'\n                             .format(input.dim()))\n        super(InstanceNorm3d, self)._check_input_dim(input)\n", "path": "torch/nn/modules/instancenorm.py"}]}