Not found on multiline type annotation

username: aryan_461
cooked: <p>Hi,<br>
I have a preprocess class that has two methods other than <code>forward</code>. when I try to sctrip the model this RunTime error apears:</p>
<pre><code class="lang-auto">Traceback (most recent call last):
  File "/projects/src/preprocess_script.py", line 99, in &lt;module&gt;
    scripted_prep = torch.jit.script(prep)
  File "/home/.conda/envs/GC/lib/python3.6/site-packages/torch/jit/__init__.py", line 1261, in script
    return torch.jit._recursive.create_script_module(obj, torch.jit._recursive.infer_methods_to_compile)
  File "/home/.conda/envs/GC/lib/python3.6/site-packages/torch/jit/_recursive.py", line 305, in create_script_module
    return create_script_module_impl(nn_module, concrete_type, stubs_fn)
  File "/home/.conda/envs/GC/lib/python3.6/site-packages/torch/jit/_recursive.py", line 361, in create_script_module_impl
    create_methods_from_stubs(concrete_type, stubs)
  File "/home/.conda/envs/GC/lib/python3.6/site-packages/torch/jit/_recursive.py", line 279, in create_methods_from_stubs
    concrete_type._create_methods(defs, rcbs, defaults)
  File "/home/.conda/envs/GC/lib/python3.6/site-packages/torch/jit/_recursive.py", line 583, in compile_unbound_method
    stub = make_stub(fn)
  File "/home/.conda/envs/GC/lib/python3.6/site-packages/torch/jit/_recursive.py", line 34, in make_stub
    ast = torch.jit.get_jit_def(func, self_name="RecursiveScriptModule")
  File "/home/.conda/envs/GC/lib/python3.6/site-packages/torch/jit/frontend.py", line 171, in get_jit_def
    type_line = torch.jit.annotations.get_type_line(source)
  File "/home/.conda/envs/GC/lib/python3.6/site-packages/torch/jit/annotations.py", line 202, in get_type_line
    raise RuntimeError("Return type line '# type: (...) -&gt; ...' not found on multiline "
RuntimeError: Return type line '# type: (...) -&gt; ...' not found on multiline type annotation
(See PEP 484 https://www.python.org/dev/peps/pep-0484/#suggested-syntax-for-python-2-7-and-straddling-code)

Process finished with exit code 1


</code></pre>
<p>I found out that one of the methods makes this error but even I commented the whole method code and just remain:</p>
<pre><code class="lang-auto">def from_tensors(self):
    pass
</code></pre>
<p>still get the same error.</p>
<p>this is my forward code:</p>
<pre><code class="lang-auto">    def forward(self, im_in):
        images = im_in.permute(2, 0, 1).to('cpu')        
        images = self.normalizer(images)
        images = self.from_tensors([images], 3)  #this line raises error

        return images
</code></pre>

username: RoySadaka
cooked: <p>If from_tensors is doing “pass” then calling:<br>
<code>images = self.from_tensors([images], 3)</code><br>
is setting <code>images</code> to <code>None</code></p>
<p>But nonetheless, can you post the original implementation of <code>from_tesnsors</code> ? (and <code>normalizer</code>)</p>
<p>Roy.</p>

username: aryan_461
cooked: <p>thanks for responding.<br>
I found that there is <code># type</code> in one of my comments and even I commented the whole (code and comments) jit still could see that and took that as a command. after removig that comment the error gone.</p>