docs: def encode_params(self, data=None, **kwargs):
          """
          Encode parameters in a piece of data.
          Will successfully encode parameters when passed as a dict or a list of
          2-tuples. Order is retained if data is a list of 2-tuples but arbitrary
          if parameters are supplied as a dict.
          """
          collection_format = kwargs.get("collection_format", self.collection_format)
          output_str = kwargs.get("output_str", self.output_str)
          sort = kwargs.get("sort", self.sort)
  
          if data is None:
              return "", self.content_type
          elif isinstance(data, (str, bytes)):
              return data, self.content_type
          elif hasattr(data, 'read'):
              return data, self.content_type
          elif collection_format == 'multi' and hasattr(data, '__iter__'):
              result = []
              for k, vs in to_key_val_list(data, sort=sort):
                  if isinstance(vs, basestring) or not hasattr(vs, '__iter__'):
                      vs = [vs]
                  for v in vs:
                      result.append(
                          (k.encode('utf-8') if isinstance(k, str) else k,
                           v.encode('utf-8') if isinstance(v, str) else to_string(v, lang=output_str)))
              return urlencode(result, doseq=True), self.content_type
          elif collection_format == 'encoded' and hasattr(data, '__iter__'):
              return urlencode(data, doseq=False), self.content_type
          elif hasattr(data, '__iter__'):
              results = []
              for k, vs in to_key_val_dict(data).items():
                  if isinstance(vs, list):
                      v = self.COLLECTION_SEPARATORS[collection_format].join(quote_plus(e) for e in vs)
                      key = k + '[]'
                  else:
                      v = quote_plus(vs)
                      key = k
                  results.append("%s=%s" % (key, v))
  
              return '&'.join(results), self.content_type
          else:
              return data, self.content_type