<h2 dir="auto"><g-emoji class="g-emoji" alias="bug" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41b.png">🐛</g-emoji> Bug</h2>
<h2 dir="auto">To Reproduce</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import torch


MY_STR_CONST = &quot;Hi, I am a string, please realize I am a constant&quot;


@torch.jit.script
def fn():
    return MY_STR_CONST


print(fn())"><pre class="notranslate"><code class="notranslate">import torch


MY_STR_CONST = "Hi, I am a string, please realize I am a constant"


@torch.jit.script
def fn():
    return MY_STR_CONST


print(fn())
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;closed_over_string.py&quot;, line 8, in &lt;module&gt;
    def fn():
  File &quot;/private/home/ycao/miniconda3/envs/pytorch/lib/python3.8/site-packages/torch/jit/_script.py&quot;, line 929, in script
    fn = torch._C._jit_script_compile(
RuntimeError:
python value of type 'str' cannot be used as a value:
  File &quot;closed_over_string.py&quot;, line 9
@torch.jit.script
def fn():
    return MY_STR_CONST
           ~~~~~~~~~~~~ &lt;--- HERE"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "closed_over_string.py", line 8, in &lt;module&gt;
    def fn():
  File "/private/home/ycao/miniconda3/envs/pytorch/lib/python3.8/site-packages/torch/jit/_script.py", line 929, in script
    fn = torch._C._jit_script_compile(
RuntimeError:
python value of type 'str' cannot be used as a value:
  File "closed_over_string.py", line 9
@torch.jit.script
def fn():
    return MY_STR_CONST
           ~~~~~~~~~~~~ &lt;--- HERE
</code></pre></div>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">fn() should return constant string</p>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/suo/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/suo">@suo</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/gmagogsfm/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/gmagogsfm">@gmagogsfm</a></p>
<p dir="auto">From common errors in ParityBench</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="compile,58,RuntimeError: python value of type 'str' cannot be used as a value:,&quot;RuntimeError: 
python value of type 'str' cannot be used as a value:
  File &quot;&quot;/tmp/paritybenchydc_9oju/pbg51yh9q6.py&quot;&quot;, line 51
    def forward(self, x):
        x = functional.batch_norm(x, self.running_mean, self.running_var, self.weight, self.bias, self.training, self.momentum, self.eps)
        if self.activation == ACT_RELU:
                              ~~~~~~~~ &lt;--- HERE
            return functional.relu(x, inplace=True)
        elif self.activation == ACT_LEAKY_RELU:"><pre class="notranslate"><code class="notranslate">compile,58,RuntimeError: python value of type 'str' cannot be used as a value:,"RuntimeError: 
python value of type 'str' cannot be used as a value:
  File ""/tmp/paritybenchydc_9oju/pbg51yh9q6.py"", line 51
    def forward(self, x):
        x = functional.batch_norm(x, self.running_mean, self.running_var, self.weight, self.bias, self.training, self.momentum, self.eps)
        if self.activation == ACT_RELU:
                              ~~~~~~~~ &lt;--- HERE
            return functional.relu(x, inplace=True)
        elif self.activation == ACT_LEAKY_RELU:
</code></pre></div>
<p dir="auto">Code example is <a href="https://github.com/jansel/pytorch-jit-paritybench/blob/6c23f5bcbed5ad85ac21573024748b335b8019eb/generated/test_zllrunning_face_parsing_PyTorch.py#L533">here</a></p>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/suo/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/suo">@suo</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/gmagogsfm/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/gmagogsfm">@gmagogsfm</a></p>