Is this a gast version issue?

  

      github.com/deepmind/sonnet
  

  
    
  
	  
  

  
    
      Import error  1
    

    
      
        opened 
        
          
        
        Sep 10, 2019
      
      

        
          closed 
        
          
        
        Sep 10, 2019
      
        

      
        
          
          ignacio-rocco
        
      
    

    
    
  


  
    I created a fresh conda environment with python 3.7.4 and installed tf2 and sonn…et2 with:
```
$ pip install "tensorflow-gpu>=2.0.0rc0" --pre
$ pip install "dm-sonnet>=2.0.0b0" --pre
```
However, when I try to import sonnet I get the following error:
```
Python 3.7.4 (default, Aug 13 2019, 20:35:49)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> import sonnet as snt
Traceback (most recent call last):
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/impl/api.py", line 614, in to_graph
    return conversion.convert(entity, program_ctx)
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 322, in convert
    free_nonglobal_var_names)
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 240, in _convert_with_cache
    entity, program_ctx)
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 469, in convert_entity_to_ast
    nodes, name, entity_info = convert_func_to_ast(o, program_ctx)
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 669, in convert_func_to_ast
    node = node_to_graph(node, context)
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/impl/conversion.py", line 699, in node_to_graph
    node = converter.apply_(node, context, function_scopes)
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/core/converter.py", line 409, in apply_
    node = converter_module.transform(node, context)
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/converters/function_scopes.py", line 120, in transform
    return FunctionBodyTransformer(ctx).visit(node)
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/core/converter.py", line 346, in visit
    return super(Base, self).visit(node)
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/pyct/transformer.py", line 480, in visit
    result = super(Base, self).visit(node)
  File "/anaconda3/envs/sonnet/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/converters/function_scopes.py", line 87, in visit_FunctionDef
    node = self.generic_visit(node)
  File "/anaconda3/envs/sonnet/lib/python3.7/ast.py", line 317, in generic_visit
    value = self.visit(value)
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/core/converter.py", line 346, in visit
    return super(Base, self).visit(node)
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/pyct/transformer.py", line 480, in visit
    result = super(Base, self).visit(node)
  File "/anaconda3/envs/sonnet/lib/python3.7/ast.py", line 262, in visit
    return visitor(node)
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/converters/function_scopes.py", line 44, in visit_Return
    value=node.value)
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/pyct/templates.py", line 261, in replace
    replacements[k] = _convert_to_ast(replacements[k])
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/pyct/templates.py", line 223, in _convert_to_ast
    return gast.Name(id=n, ctx=None, annotation=None)
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/gast/gast.py", line 19, in create_node
    format(Name, nbparam, len(Fields))
AssertionError: Bad argument number for Name: 3, expecting 4

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/sonnet/__init__.py", line 25, in <module>
    from sonnet import nets
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/sonnet/nets.py", line 22, in <module>
    from sonnet.src.nets.cifar10_convnet import Cifar10ConvNet
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/sonnet/src/nets/cifar10_convnet.py", line 22, in <module>
    from sonnet.src import batch_norm
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/sonnet/src/batch_norm.py", line 30, in <module>
    class BaseBatchNorm(base.Module):
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/sonnet/src/batch_norm.py", line 126, in BaseBatchNorm
    scale=None, offset=None):
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/sonnet/src/utils.py", line 172, in smart_autograph
    f_autograph = tf.autograph.to_graph(f)
  File "/anaconda3/envs/sonnet/lib/python3.7/site-packages/tensorflow_core/python/autograph/impl/api.py", line 618, in to_graph
    entity, e.__class__.__name__, str(e)))
tensorflow.python.autograph.impl.api.ConversionError: converting <function BaseBatchNorm.__call__ at 0x7fb3de0db5f0>: AssertionError: Bad argument number for Name: 3, expecting 4
```