code: def no_grad(no_grad_=True):
      """No gradients for the whole network.
  
      No gradients are required when creating a network, such that when the forward pass is executed,
      all intermediate buffers except for the leafs in the network are gone at the same time, resulting in
      memory optimization.
  
      This is useful for example when an output of a pre-trained network is used for an input to
      another network, where the first pre-trained network does not need to be fine-tuned, but the other
      network is optimized.
  
      Args:
  
          no_grad_ (bool): No gradient flag. Default is True.
  
      Example:
  
      .. code-block:: python
  
          with nn.no_grad():
              output0 = <Network0>(<input0>)
  
          output1 = <Network1>(<input1>, output0)
          loss = <Loss>(output1, <ground_truth>)
          loss.forward(clear_no_need_grad=True)
  
  
      This context also works in the dynamic mode.
  
      .. code-block:: python
  
          with nn.auto_forward(), nn.no_grad():
              output0 = <Network0>(<input0>)
  
      Note:
          When working with the static network, the need_grad property of the input (e.g., input image) must be False
          and do not forget to add `<root>.forward(clear_no_need_grad=True)`;
          otherwise, all intermediate buffers are not gone as expected.
      """
  
      global current_no_grad
      prev_no_grad = current_no_grad
      current_no_grad = no_grad_
      try:
          yield
      finally:
          current_no_grad = prev_no_grad
  
imports: from six import iteritems
  from contextlib import contextmanager
  from collections import OrderedDict
  import google.protobuf.text_format
  import numpy
  import os
  import shutil
  import tempfile
  import zipfile
  import nnabla
  from nnabla.logger import logger
  import nnabla.utils.nnabla_pb2
  from nnabla.utils.get_file_handle import get_parameter_file_loader, load_files, FileHandlerContext
  from nnabla.utils.get_file_handle import get_file_handle_save, get_parameter_file_savers, save_files
  import warnings
label_desc: Use image node_id 2 for calling a global function with example usage: no_grad(no_grad_) without return types