code: def model_card_get_pooling_function(pooling_mode):
      if pooling_mode == "max":
          return (
              "max_pooling",
              """
  # Max Pooling - Take the max value over time for every dimension. 
  def max_pooling(model_output, attention_mask):
      token_embeddings = model_output[0] #First element of model_output contains all token embeddings
      input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
      token_embeddings[input_mask_expanded == 0] = -1e9  # Set padding tokens to large negative value
      return torch.max(token_embeddings, 1)[0]
  """,
          )
      elif pooling_mode == "mean":
          return (
              "mean_pooling",
              """
  #Mean Pooling - Take attention mask into account for correct averaging
  def mean_pooling(model_output, attention_mask):
      token_embeddings = model_output[0] #First element of model_output contains all token embeddings
      input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
      return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
  """,
          )
  
      elif pooling_mode == "cls":
          return (
              "cls_pooling",
              """
  def cls_pooling(model_output, attention_mask):
      return model_output[0][:,0]
  """,
          )
  
imports: import logging
  from .util import fullname
label_desc: Use image node_id 1 for calling the ModelCardTemplate obj's underlying member method code with example usage: obj.model_card_get_pooling_function(pooling_mode) and returns: str,  str, str,  str, str,  str