code: def test_datafile_init(dataset_ncf_files_sorted):
      train_path, _, _ = dataset_ncf_files_sorted
      train = pd.read_csv(train_path)
      users = train[DEFAULT_USER_COL].unique()
      items = train[DEFAULT_ITEM_COL].unique()
      datafile = DataFile(
          train_path,
          DEFAULT_USER_COL,
          DEFAULT_ITEM_COL,
          DEFAULT_RATING_COL,
          col_test_batch=None,
          binary=True,
      )
      assert set(datafile.users) == set(users)
      assert set(datafile.items) == set(items)
      assert set(datafile.user2id.keys()) == set(users)
      assert set(datafile.item2id.keys()) == set(items)
      assert len(set(datafile.user2id.values())) == len(users)
      assert len(set(datafile.item2id.values())) == len(items)
      assert datafile.data_len == train.shape[0]
  
      datafile_records = []
      with datafile as f:
          for line in f:
              datafile_records.append(
                  {
                      DEFAULT_USER_COL: line[DEFAULT_USER_COL],
                      DEFAULT_ITEM_COL: line[DEFAULT_ITEM_COL],
                      DEFAULT_RATING_COL: line[DEFAULT_RATING_COL],
                  }
              )
      datafile_df = pd.DataFrame.from_records(datafile_records)
      assert datafile_df.shape[0] == train.shape[0]
  
      # test the data loaded from the file is the same as original data
      datafile_df = datafile_df.sort_values(
          by=[DEFAULT_USER_COL, DEFAULT_ITEM_COL]
      )
      train = train.sort_values(by=[DEFAULT_USER_COL, DEFAULT_ITEM_COL])
      train[DEFAULT_RATING_COL] = train[DEFAULT_RATING_COL].apply(
          lambda x: float(x > 0)
      )
      train = train.drop(DEFAULT_TIMESTAMP_COL, axis=1)
      assert train.equals(datafile_df)
  
      # test data can be loaded for a valid user and it throws exception for invalid user
      user = train[DEFAULT_USER_COL].iloc[0]
      missing_user = train[DEFAULT_USER_COL].iloc[-1] + 1
      with datafile as f:
          user_data = f.load_data(user)
          assert user_data[DEFAULT_USER_COL].iloc[0] == user
          with pytest.raises(MissingUserException):
              user_data == f.load_data(missing_user)
  
file_path: recommenders/tests/unit/recommenders/models/test_ncf_dataset.py
imports: import os
  import pytest
  import pandas
  from recommenders.utils.constants import DEFAULT_USER_COL, DEFAULT_ITEM_COL, DEFAULT_RATING_COL, DEFAULT_TIMESTAMP_COL
  from recommenders.models.ncf.dataset import DataFile, NegativeSampler, Dataset, EmptyFileException, MissingFieldsException, FileNotSortedException, MissingUserException
label_desc: Use image node_id 1 for calling a global function with example usage: test_datafile_init(dataset_ncf_files_sorted) without return types