I am new to JIT scripting and don’t know what this error means, and have not found this zero_grad error online nor any related errors whose solutions seem to make sense here. What am I doing wrong here?
The error is this (see gist for full error):
Tried to access nonexistent attribute or method 'zero_grad' of type 'Tensor (inferred)'.

The full repro is here:
  
      gist.github.com
  
  
    https://gist.github.com/alannnna/008106cdee4ced848780ed1d829f57d2 24
bench.py
import time

import torch

from mnist import Net, DEFAULTS, train_example


def make_net():
    torch.manual_seed(1234)
    model = Net()
This file has been truncated. show original
error.txt
$ python bench.py 

7.002076864242554
Traceback (most recent call last):
  File "bench.py", line 50, in <module>
    try_jit()
  File "bench.py", line 31, in try_jit
    scripted_train_example = torch.jit.script(train_example)
  File "/Users/me/blah/blah/venv/lib/python3.7/site-packages/torch/jit/_script.py", line 940, in script
    qualified_name, ast, _rcb, get_default_args(obj)
This file has been truncated. show original
mnist.py
from __future__ import print_function
import argparse
import time
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms


This file has been truncated. show original