code: def _check_nan(self, epoch_data: EpochData) -> None:
          
          for stream_name in epoch_data.keys():
              stream_data = epoch_data[stream_name]
              variables = self._variables if self._variables is not None else stream_data.keys()
              for variable in variables:
                  if variable not in stream_data:
                      raise KeyError('Variable `{}` to be nan-checked was not found in the batch data for stream `{}`. '
                                     'Available variables are `{}`.'.format(variable, stream_name, stream_data.keys()))
  
                  value = stream_data[variable]
                  if self._is_nan(variable, value):
                      raise TrainingTerminated('Variable `{}` is NaN.'.format(variable))
docs: Raise an exception when some of the monitored data is NaN.
  
          :param epoch_data: epoch data checked
          :raise KeyError: if the specified variable is not found in the stream
          :raise ValueError: if the variable value is of unsupported type and ``self._on_unknown_type`` is set to ``error``