code: def adjust_length_to_model(length, max_sequence_length):
      if length < 0 and max_sequence_length > 0:
          length = max_sequence_length
      elif 0 < max_sequence_length < length:
          length = max_sequence_length  # No generation bigger than model size
      elif length < 0:
          length = MAX_LENGTH  # avoid infinite loop
      return length
  
file_path: adapters/examples/pytorch/text-generation/run_generation.py
imports: import argparse
  import logging
  import numpy
  import torch
  import adapters
  from transformers import CTRLLMHeadModel, CTRLTokenizer, GPT2LMHeadModel, GPT2Tokenizer, OpenAIGPTLMHeadModel, OpenAIGPTTokenizer, TransfoXLLMHeadModel, TransfoXLTokenizer, XLMTokenizer, XLMWithLMHeadModel, XLNetLMHeadModel, XLNetTokenizer
label_desc: Use image node_id 6 for calling a global function with example usage: adjust_length_to_model(length, max_sequence_length) and returns: length