You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: tl_stats_broadcast_stats_gen.go
    path of file: ./repos/td/tg
    
    the code of the file until where you have to start completion: // Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"github.com/gotd/td/bin"
	"github.com/gotd/td/tdjson"
	"github.com/gotd/td/tdp"
	"github.com/gotd/td/tgerr"
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// StatsBroadcastStats represents TL type `stats.broadcastStats#396ca5fc`.
// Channel statisticsÂ¹.
//
// Links:
//  1. https://core.telegram.org/api/stats
//
// See https://core.telegram.org/constructor/stats.broadcastStats for reference.
type StatsBroadcastStats struct {
	// Period in consideration
	Period StatsDateRangeDays
	// Follower count change for period in consideration
	Followers StatsAbsValueAndPrev
	// total_viewcount/postcount, for posts posted during the period in consideration. Note
	// that in this case, current refers to the period in consideration (min_date till
	// max_date), and prev refers to the previous period ((min_date - (max_date - min_date))
	// till min_date).
	ViewsPerPost StatsAbsValueAndPrev
	// total_sharecount/postcount, for posts posted during the period in consideration. Note
	// that in this case, current refers to the period in consideration (min_date till
	// max_date), and prev refers to the previous period ((min_date - (max_date - min_date))
	// till min_date)
	SharesPerPost StatsAbsValueAndPrev
	// total_reactions/postcount, for posts posted during the period in consideration. Note
	// that in this case, current refers to the period in consideration (min_date till
	// max_date), and prev refers 
    
func (b *StatsBroadcastStats) EncodeBare(buf *bin.Buffer) error {
	if b == nil {
		return fmt.Errorf("can't encode stats.broadcastStats#396ca5fc as nil")
	}
	if err := b.Period.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field period: %w", err)
	}
	if err := b.Followers.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field followers: %w", err)
	}
	if err := b.ViewsPerPost.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field views_per_post: %w", err)
	}
	if err := b.SharesPerPost.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field shares_per_post: %w", err)
	}
	if err := b.ReactionsPerPost.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field reactions_per_post: %w", err)
	}
	if err := b.ViewsPerStory.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field views_per_story: %w", err)
	}
	if err := b.SharesPerStory.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field shares_per_story: %w", err)
	}
	if err := b.ReactionsPerStory.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field reactions_per_story: %w", err)
	}
	if err := b.EnabledNotifications.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field enabled_notifications: %w", err)
	}
	if b.GrowthGraph == nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field growth_graph is nil")
	}
	if err := b.GrowthGraph.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field growth_graph: %w", err)
	}
	if b.FollowersGraph == nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field followers_graph is nil")
	}
	if err := b.FollowersGraph.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field followers_graph: %w", err)
	}
	if b.MuteGraph == nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field mute_graph is nil")
	}
	if err := b.MuteGraph.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field mute_graph: %w", err)
	}
	if b.TopHoursGraph == nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field top_hours_graph is nil")
	}
	if err := b.TopHoursGraph.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field top_hours_graph: %w", err)
	}
	if b.InteractionsGraph == nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field interactions_graph is nil")
	}
	if err := b.InteractionsGraph.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field interactions_graph: %w", err)
	}
	if b.IvInteractionsGraph == nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field iv_interactions_graph is nil")
	}
	if err := b.IvInteractionsGraph.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field iv_interactions_graph: %w", err)
	}
	if b.ViewsBySourceGraph == nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field views_by_source_graph is nil")
	}
	if err := b.ViewsBySourceGraph.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field views_by_source_graph: %w", err)
	}
	if b.NewFollowersBySourceGraph == nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field new_followers_by_source_graph is nil")
	}
	if err := b.NewFollowersBySourceGraph.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field new_followers_by_source_graph: %w", err)
	}
	if b.LanguagesGraph == nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field languages_graph is nil")
	}
	if err := b.LanguagesGraph.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field languages_graph: %w", err)
	}
	if b.ReactionsByEmotionGraph == nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field reactions_by_emotion_graph is nil")
	}
	if err := b.ReactionsByEmotionGraph.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field reactions_by_emotion_graph: %w", err)
	}
	if b.StoryInteractionsGraph == nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field story_interactions_graph is nil")
	}
	if err := b.StoryInteractionsGraph.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field story_interactions_graph: %w", err)
	}
	if b.StoryReactionsByEmotionGraph == nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field story_reactions_by_emotion_graph is nil")
	}
	if err := b.StoryReactionsByEmotionGraph.Encode(buf); err != nil {
		return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field story_reactions_by_emotion_graph: %w", err)
	}
	buf.PutVectorHeader(len(b.RecentPostsInteractions))
	for idx, v := range b.RecentPostsInteractions {
		if v == nil {
			return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field recent_posts_interactions element with index %d is nil", idx)
		}
		if err := v.Encode(buf); err != nil {
			return fmt.Errorf("unable to encode stats.broadcastStats#396ca5fc: field recent_posts_interactions element with index %d: %w", idx, err)
		}
	}
	return nil
}