code: def get_counted_number(context, config, variables, **kw):
      
      # This "context" is defined by the user in the Setup and can be actually
      # anything. However, we assume it is something like "sample" or similar
      ctx = config.get("context")
  
      # get object behind the context name (falls back to the current context)
      obj = variables.get(ctx, context)
  
      # get the counter type, which is either "backreference" or "contained"
      counter_type = config.get("counter_type")
  
      # the counter reference is either the "relationship" for
      # "backreference" or the meta type for contained objects
      counter_reference = config.get("counter_reference")
  
      # This should be a list of existing items, including the current context
      # object
      seq_items = get_objects_in_sequence(obj, counter_type, counter_reference)
  
      number = len(seq_items)
      return number
docs: Compute the number for the sequence type "Counter"