code: def get_segment_leaderboard(self, segment_id, gender=None, age_group=None, weight_class=None,
                                  following=None, club_id=None, timeframe=None, top_results_limit=None,
                                  page=None, context_entries = None):
          params = {}
          if gender is not None:
              if gender.upper() not in ('M', 'F'):
                  raise ValueError("Invalid gender: {0}. Possible values: 'M' or 'F'".format(gender))
              params['gender'] = gender
          valid_age_groups = ('0_24', '25_34', '35_44', '45_54', '55_64', '65_plus')
          if age_group is not None:
              if not age_group in valid_age_groups:
                  raise ValueError("Invalid age group: {0}.  Possible values: {1!r}".format(age_group, valid_age_groups))
              params['age_group'] = age_group
          valid_weight_classes = ('0_124', '125_149', '150_164', '165_179', '180_199', '200_plus',
                                  '0_54', '55_64', '65_74', '75_84', '85_94', '95_plus')
          if weight_class is not None:
              if not weight_class in valid_weight_classes:
                  raise ValueError("Invalid weight class: {0}.  Possible values: {1!r}".format(weight_class, valid_weight_classes))
              params['weight_class'] = weight_class
          if following is not None:
              params['following'] = int(following)
          if club_id is not None:
              params['club_id'] = club_id
          if timeframe is not None:
              valid_timeframes = 'this_year', 'this_month', 'this_week', 'today'
              if not timeframe in valid_timeframes:
                  raise ValueError("Invalid timeframe: {0}.  Possible values: {1!r}".format(timeframe, valid_timeframes))
              params['date_range'] = timeframe
          if top_results_limit is not None:
              params['per_page'] = top_results_limit
          if page is not None:
              params['page'] = page
          if context_entries is not None:
              params['context_entries'] = context_entries
          return model.SegmentLeaderboard.deserialize(self.protocol.get('/segments/{id}/leaderboard',
                                                                        id=segment_id,
                                                                        **params),
                                                      bind_client=self)