code: def set_trainable(
      model: Union[tf.Module, Iterable[tf.Module]], flag: bool
  ) -> None:
      """
      Set trainable flag for all :class:`tf.Variable`\ s and :class:`gpflow.Parameter`\ s in a
      :class:`tf.Module` or collection of :class:`tf.Module`\ s.
      """
      modules = [model] if isinstance(model, tf.Module) else model
  
      for mod in modules:
          for variable in mod.variables:
              variable._trainable = flag
  
file_path: GPflow/gpflow/utilities/misc.py
imports: from typing import Callable, Iterable, List, Optional, Union
  import tensorflow
  import tensorflow_probability
  from check_shapes import check_shapes
  from ..base import TensorData
  from ..config import default_float, default_int
label_desc: Use image node_id 3 for calling a global function with example usage: set_trainable(model, flag) without return types