input: Write a function to analyze the sentiment of given text and categorize it into positive, negative, and neutral sentiments. If the majority of sentences are classified as 'pos', return 'positive'. If the majority are 'neg', return 'negative'. If there is an equal number of 'pos' and 'neg', return 'neutral'. The function should utilize NLTK's NaiveBayesClassifier for sentence classification.
  
  assert analyze_sentiment("I love this product. It's amazing!") == 'positive'
  assert analyze_sentiment("This product is terrible. I hate it.") == 'negative'
  assert analyze_sentiment("It's okay, not great but not bad either.") == 'neutral'
  assert analyze_sentiment("I feel neutral about this.") == 'neutral'
  assert analyze_sentiment("") == 'neutral'
output: def analyze_sentiment(text):
      from nltk.classify import NaiveBayesClassifier
      from nltk.tokenize import sent_tokenize
      from nltk.corpus import subjectivity
      from nltk.sentiment import SentimentAnalyzer
  
      nltk.download('subjectivity')
      nltk.download('punkt')
  
      subj_docs = [(sent, 'subj') for sent in subjectivity.sents(categories='subj')]
      obj_docs = [(sent, 'obj') for sent in subjectivity.sents(categories='obj')]
      train_data = subj_docs[:4000] + obj_docs[:4000]
  
      sentim_analyzer = SentimentAnalyzer()
      all_words_neg = sentim_analyzer.all_words([mark_negation(doc) for doc in train_data])
      unigram_feats = sentim_analyzer.unigram_word_feats(all_words_neg, min_freq=4)
      sentim_analyzer.add_feat_extractor(extract_unigram_feats, unigrams=unigram_feats)
      training_set = sentim_analyzer.apply_features(train_data)
      trainer = NaiveBayesClassifier.train
      classifier = sentim_analyzer.train(trainer, training_set)
  
      sentences = sent_tokenize(text)
      pos_count = 0
      neg_count = 0
  
      for sentence in sentences:
          sentiment = classifier.classify(extract_unigram_feats(sentence.split(), unigram_feats))
          if sentiment == 'subj':
              pos_count += 1
          elif sentiment == 'obj':
              neg_count += 1
  
      if pos_count > neg_count:
          return 'positive'
      elif neg_count > pos_count:
          return 'negative'
      else:
          return 'neutral'