Repository: tensorflow
Issue: AutoGraph cannot handle python 3.10's structural pattern matching
Labels: stat:awaiting tensorflower,type:bug,comp:autograph,TF 2.9

<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Bug

### Source

binary

### Tensorflow Version

2.9.2

### Custom Code

No

### OS Platform and Distribution

macOS 12.5

### Mobile device

none

### Python version

3.10

### Bazel version

_No response_

### GCC/Compiler version

_No response_

### CUDA/cuDNN version

none

### GPU model and memory

Apple's METAL (though unlikely to be relevant here)

### Current Behaviour?

Trying to AutoGraph a function containing a [PEP 634/635/636 structural pattern matching statement](https://peps.python.org/pep-0634/) from python 3.10 (i.e. `match/case`) results in the `WARNING:tensorflow:AutoGraph could not transform <function test at 0x2c4c99120> and will run it as-is.`

### Standalone code to reproduce the issue

```python
import tensorflow as tf

@tf.function
def test(x, selector):
    match selector:
        case "square":
            return x**2
        case "double":
            return x*2.
        case _:
            raise ValueError
            
test(tf.linspace(-1,1,10),"double")
```


### Relevant log output

```shell
INFO:tensorflow:Error transforming entity <function test at 0x2c4c99120>
Traceback (most recent call last):
  File "/Users/yves/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/autograph/impl/api.py", line 427, in converted_call
    converted_f = _convert_actual(target_entity, program_ctx)
  File "/Users/yves/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/autograph/impl/api.py", line 269, in _convert_actual
    transformed, module, source_map = _TRANSPILER.transform(entity, program_ctx)
  File "/Users/yves/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/autograph/pyct/transpiler.py", line 282, in transform
    return self.transform_function(obj, user_context)
  File "/Users/yves/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/autograph/pyct/transpiler.py", line 466, in transform_function
    nodes, ctx = super(PyToPy, self).transform_function(fn, user_context)
  File "/Users/yves/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/autograph/pyct/transpiler.py", line 359, in transform_function
    result = self.transform_ast(node, context)
  File "/Users/yves/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/autograph/impl/api.py", line 237, in transform_ast
    node = self.initial_analysis(node, ctx)
  File "/Users/yves/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/autograph/impl/api.py", line 223, in initial_analysis
    graphs = cfg.build(node)
  File "/Users/yves/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/autograph/pyct/cfg.py", line 970, in build
    visitor.visit(node)
  File "/Users/yves/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ast.py", line 410, in visit
    return visitor(node)
  File "/Users/yves/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/autograph/pyct/cfg.py", line 766, in visit_FunctionDef
    self._process_function_def(node, is_lambda=False)
  File "/Users/yves/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/autograph/pyct/cfg.py", line 757, in _process_function_def
    self.visit(stmt)
  File "/Users/yves/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ast.py", line 410, in visit
    return visitor(node)
  File "/Users/yves/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ast.py", line 414, in generic_visit
    for field, value in iter_fields(node):
  File "/Users/yves/.pyenv/versions/3.10.4/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ast.py", line 252, in iter_fields
    for field in node._fields:
AttributeError: 'NoneType' object has no attribute '_fields'
```
</details>