The semantics of passing object references on procedure calls in python is a bit more complicated than that. Objects are passed “by reference”, not “by value”. So that means whether the global object is modified by the function all depends on how the function is implemented. If it assigns anything to that object or elements of that object without first doing a “deepcopy”, then it will modify the global data. So I believe the global object does get modified in that case, but there is also the question of the statefulness of the TF mechanisms to do with computing gradients.
Here’s a thread which discusses that point in more detail and shows some examples of the pitfalls of object references in python. Make sure to also read this later post on that same thread.
We’re swimming in pretty deep water here with OOP in python, so there is a lot to know. Of course once you graduate to OOP, python is just the framework. You also have to invest the effort to understand the properties of the various classes you are dealing with. Fortunately the TF docs are pretty good in general, but there’s a lot of them.