code: def test_count_null(pd_es):
      class Count(AggregationPrimitive):
          name = "count"
          input_types = [
              [ColumnSchema(semantic_tags={"foreign_key"})],
              [ColumnSchema()],
          ]
          return_type = ColumnSchema(semantic_tags={"numeric"})
          stack_on_self = False
  
          def __init__(self, count_null=True):
              self.count_null = count_null
  
          def get_function(self):
              def count_func(values):
                  if self.count_null:
                      values = values.fillna(0)
  
                  return values.count()
  
              return count_func
  
          def generate_name(
              self,
              base_feature_names,
              relationship_path_name,
              parent_dataframe_name,
              where_str,
              use_prev_str,
          ):
              return "COUNT(%s%s%s)" % (
                  relationship_path_name,
                  where_str,
                  use_prev_str,
              )
  
      count_null = Feature(
          pd_es["log"].ww["value"],
          parent_dataframe_name="sessions",
          primitive=Count(count_null=True),
      )
      feature_matrix = calculate_feature_matrix(
          [count_null], entityset=pd_es
      )
      values = [5, 4, 1, 2, 3, 2]
      assert (values == feature_matrix[count_null.get_name()]).all()
  
imports: from datetime import datetime
  from inspect import isclass
  from math import isnan
  import numpy
  import pandas
  import pytest
  from woodwork.column_schema import ColumnSchema
  from woodwork.logical_types import Datetime
  from featuretools import AggregationFeature, Feature, IdentityFeature, Timedelta, calculate_feature_matrix, dfs, primitives
  from featuretools.entityset.relationship import RelationshipPath
  from featuretools.feature_base.cache import feature_cache
  from featuretools.primitives import Count, Max, Mean, Median, NMostCommon, NumTrue, NumUnique, Sum, TimeSinceFirst, TimeSinceLast, get_aggregation_primitives
  from featuretools.primitives.base import AggregationPrimitive
  from featuretools.synthesis.deep_feature_synthesis import DeepFeatureSynthesis, match
  from featuretools.tests.testing_utils import backward_path, feature_with_name, to_pandas
  from featuretools.utils.gen_utils import Library
label_desc: Use image node_id 4 for calling a global function with example usage: test_count_null(pd_es) and returns: count_func, unknown, values