code: def test_feature_collection_serialization_roundtrip():
      col_defs = [
          ("idx", "Integer", {"index"}),
          ("t_idx", "Datetime", {"time_index"}),
          ("f_1", "Double"),
          ("f_2", "Double"),
          ("f_3", "Categorical"),
          ("f_4", "Boolean"),
          ("f_5", "NaturalLanguage"),
      ]
  
      df = generate_fake_dataframe(
          col_defs=col_defs,
      )
  
      origin_features = schema_to_features(df.ww.schema)
      features = generate_features_from_primitives(
          origin_features,
          [Absolute, MultiplyNumeric, MultiOutputPrimitiveForTest],
      )
  
      features = generate_features_from_primitives(features, [Lag])
  
      assert set([x.name for x in features]) == set(
          [
              "idx",
              "t_idx",
              "f_1",
              "f_2",
              "f_3",
              "f_4",
              "f_5",
              "ABSOLUTE(f_1)",
              "ABSOLUTE(f_2)",
              "f_1 * f_2",
              "TEST_MO(f_5)[0]",
              "TEST_MO(f_5)[1]",
              "LAG(f_1, t_idx)",
              "LAG(f_2, t_idx)",
              "LAG(f_3, t_idx)",
              "LAG(f_4, t_idx)",
              "LAG(ABSOLUTE(f_1), t_idx)",
              "LAG(ABSOLUTE(f_2), t_idx)",
              "LAG(f_1 * f_2, t_idx)",
              "LAG(TEST_MO(f_5)[1], t_idx)",
              "LAG(TEST_MO(f_5)[0], t_idx)",
          ],
      )
      fc = FeatureCollection(features=features)
      fc_dict = fc.to_dict()
  
      fc_json = json.dumps(fc_dict)
  
      fc2_dict = json.loads(fc_json)
  
      fc2 = FeatureCollection.from_dict(fc2_dict)
  
      assert fc == fc2
      lsa_features = [
          x
          for x in fc2.all_features
          if x.get_primitive_name() == "test_mo"
      ]
      assert len(lsa_features[0].related_features) == 1
  
imports: import json
  from unittest.mock import patch
  import pytest
  from woodwork.logical_types import Boolean, Double
  from featuretools.feature_discovery.feature_discovery import generate_features_from_primitives, schema_to_features
  from featuretools.feature_discovery.FeatureCollection import FeatureCollection
  from featuretools.feature_discovery.LiteFeature import LiteFeature
  from featuretools.primitives import Absolute, AddNumeric, DivideNumeric, Lag, MultiplyNumeric
  from featuretools.tests.feature_discovery.test_feature_discovery import MultiOutputPrimitiveForTest
  from featuretools.tests.testing_utils.generate_fake_dataframe import generate_fake_dataframe
label_desc: Use image node_id 8 for calling a global function with example usage: test_feature_collection_serialization_roundtrip() without return types