code: def test_NaNLabelEncoder(data, allow_nan):
      fit_data, transform_data = data
      encoder = NaNLabelEncoder(warn=False, add_nan=allow_nan)
      encoder.fit(fit_data)
      assert np.array_equal(
          encoder.inverse_transform(encoder.transform(fit_data)),
          fit_data,
      ), "Inverse transform should reverse transform"
      if not allow_nan:
          with pytest.raises(KeyError):
              encoder.transform(transform_data)
      else:
          assert (
              encoder.transform(transform_data)[0] == 0
          ), "First value should be translated to 0 if nan"
          assert (
              encoder.transform(transform_data)[-1] == 0
          ), "Last value should be translated to 0 if nan"
          assert (
              encoder.transform(fit_data)[0] > 0
          ), "First value should not be 0 if not nan"
  
file_path: pytorch-forecasting/tests/test_data/test_encoders.py
imports: from copy import deepcopy
  import itertools
  import numpy
  import pandas
  import pytest
  from sklearn.utils.validation import NotFittedError, check_is_fitted
  import torch
  from pytorch_forecasting.data import EncoderNormalizer, GroupNormalizer, MultiNormalizer, NaNLabelEncoder, TorchNormalizer
label_desc: Use image node_id 1 for calling a global function with example usage: test_NaNLabelEncoder(data, allow_nan) without return types