parameters: (self, features, labels, add_batch_size_in_params=False)
return_statement: return self._model_fn(features=features, **kwargs)
docstring: Calls the model_fn with required parameters.
docstring_summary: Calls the model_fn with required parameters.
docstring_tokens: Calls the model_fn with required parameters .
function: def _call_model_fn(self, features, labels, add_batch_size_in_params=False):
      """Calls the model_fn with required parameters."""
      model_fn_args = util.fn_args(self._model_fn)
      kwargs = {}
  
      config = copy.deepcopy(self._config)
      params = copy.deepcopy(self._params)
  
      if 'labels' in model_fn_args:
        kwargs['labels'] = labels
      else:
        if labels is not None:
          raise ValueError(
              'model_fn does not take labels, but input_fn returns labels.')
      if 'mode' in model_fn_args:
        kwargs['mode'] = self._mode
      if 'config' in model_fn_args:
        kwargs['config'] = config
      if 'params' in model_fn_args:
        kwargs['params'] = params
  
      if add_batch_size_in_params:
        if 'params' not in model_fn_args:
          raise ValueError(
              'model_fn ({}) does not include params argument, '
              'required by TPUEstimator to pass batch size as '
              'params[\'batch_size\']'.format(self._model_fn))
        if self._mode == model_fn_lib.ModeKeys.TRAIN:
          # For TPU training. `params` is never `None`.
          params[_BATCH_SIZE_KEY] = _per_shard_batch_size(self._train_batch_size,
                                                          config)
  
      return self._model_fn(features=features, **kwargs)
function_tokens: def _call_model_fn ( self , features , labels , add_batch_size_in_params = False ) : model_fn_args = util . fn_args ( self . _model_fn ) kwargs = { } config = copy . deepcopy ( self . _config ) params = copy . deepcopy ( self . _params ) if 'labels' in model_fn_args : kwargs [ 'labels' ] = labels else : if labels is not None : raise ValueError ( 'model_fn does not take labels, but input_fn returns labels.' ) if 'mode' in model_fn_args : kwargs [ 'mode' ] = self . _mode if 'config' in model_fn_args : kwargs [ 'config' ] = config if 'params' in model_fn_args : kwargs [ 'params' ] = params if add_batch_size_in_params : if 'params' not in model_fn_args : raise ValueError ( 'model_fn ({}) does not include params argument, ' 'required by TPUEstimator to pass batch size as ' 'params[\'batch_size\']' . format ( self . _model_fn ) ) if self . _mode == model_fn_lib . ModeKeys . TRAIN : # For TPU training. `params` is never `None`. params [ _BATCH_SIZE_KEY ] = _per_shard_batch_size ( self . _train_batch_size , config ) return self . _model_fn ( features = features , * * kwargs )