parameters: (self)
return_statement: return network
docstring: Build train network
docstring_summary: Build train network
docstring_tokens: Build train network
function: def _build_train_network(self):
          """Build train network"""
          network = self._network
          if self._loss_scale_manager is not None and self._optimizer is None:
              raise ValueError("The argument 'optimizer' can not be None when set 'loss_scale_manager'.")
  
          if self._optimizer:
              if self._loss_scale_manager_set:
                  network = amp.build_train_network(network,
                                                    self._optimizer,
                                                    self._loss_fn,
                                                    level=self._amp_level,
                                                    boost_level=self._boost_level,
                                                    loss_scale_manager=self._loss_scale_manager,
                                                    keep_batchnorm_fp32=self._keep_bn_fp32)
              else:
                  network = amp.build_train_network(network,
                                                    self._optimizer,
                                                    self._loss_fn,
                                                    level=self._amp_level,
                                                    boost_level=self._boost_level,
                                                    keep_batchnorm_fp32=self._keep_bn_fp32)
          elif self._loss_fn:
              if self._parallel_mode in (ParallelMode.SEMI_AUTO_PARALLEL, ParallelMode.AUTO_PARALLEL):
                  network = _VirtualDatasetCell(network)
              network = nn.WithLossCell(network, self._loss_fn)
          # If need to check if loss_fn is not None, but optimizer is None
  
          if self._parallel_mode in (ParallelMode.SEMI_AUTO_PARALLEL, ParallelMode.AUTO_PARALLEL):
              network.set_auto_parallel()
              if self._optimizer is None:
                  # In this case, multiple optimizer(s) is supposed to be included in 'self._network'
                  _set_multi_subgraphs()
          return network
function_tokens: def _build_train_network ( self ) : network = self . _network if self . _loss_scale_manager is not None and self . _optimizer is None : raise ValueError ( "The argument 'optimizer' can not be None when set 'loss_scale_manager'." ) if self . _optimizer : if self . _loss_scale_manager_set : network = amp . build_train_network ( network , self . _optimizer , self . _loss_fn , level = self . _amp_level , boost_level = self . _boost_level , loss_scale_manager = self . _loss_scale_manager , keep_batchnorm_fp32 = self . _keep_bn_fp32 ) else : network = amp . build_train_network ( network , self . _optimizer , self . _loss_fn , level = self . _amp_level , boost_level = self . _boost_level , keep_batchnorm_fp32 = self . _keep_bn_fp32 ) elif self . _loss_fn : if self . _parallel_mode in ( ParallelMode . SEMI_AUTO_PARALLEL , ParallelMode . AUTO_PARALLEL ) : network = _VirtualDatasetCell ( network ) network = nn . WithLossCell ( network , self . _loss_fn ) # If need to check if loss_fn is not None, but optimizer is None if self . _parallel_mode in ( ParallelMode . SEMI_AUTO_PARALLEL , ParallelMode . AUTO_PARALLEL ) : network . set_auto_parallel ( ) if self . _optimizer is None : # In this case, multiple optimizer(s) is supposed to be included in 'self._network' _set_multi_subgraphs ( ) return network