You could use expand_nested but some bug was fixed recently:

  

      github.com/keras-team/keras
  

  
    
  
    
  

  
    
      `expand_nested` bug fix and changing `model.summary` style 2
    

    
      keras-team:master ← krishrustagi:changes
    

    
      
        opened 
        
          
        
        Sep 12, 2021
      
      

      
        
          
          krishrustagi
        
      

      
        
          +42
          -11
        
      
    
  


  
    The bug fixing is based on PR #15251. 
There were 2 bugs with the expand_nested…:

### Bug1:
![Screenshot from 2021-09-12 13-40-58](https://user-images.githubusercontent.com/54409969/132979071-039f13b1-f09e-4900-8dee-2626a4e3e074.png)

### After Changes Bug1:
![Screenshot from 2021-09-12 13-42-07](https://user-images.githubusercontent.com/54409969/132979105-06469b57-6da5-4a3b-b501-debfd6d5eef0.png)


### Bug2:
```python3
text_file = open('summary.txt', 'w');
def print_text(text, end = "\n"):
    print(text, end = end, file = text_file)
```
Use of end = `\n` additionally.  Without it, throws an error.

### After changes Bug2:
```python3
text_file = open('summary.txt', 'w');
def print_text(text):
    print(text, file = text_file)
````

**Also, I have tried to change the style of `model.summary` by replacing `_` with space that looks good and less chaotic with and without expand_nested**

### expand_nested=False
![Screenshot from 2021-09-12 13-49-31](https://user-images.githubusercontent.com/54409969/132979356-5b9cbd7d-b0d4-4c4e-9f0f-b74cbb382682.png)

### expand_nested=True
![Screenshot from 2021-09-12 13-48-49](https://user-images.githubusercontent.com/54409969/132979340-f79582fe-e007-45f9-a8d0-7055474deffe.png)



**Note:** I need to update the test cases also. But before that, please look into the changes.
  

  

  
    
    
  

  


So probably you could try with a TF 2.7rc release.