code: def encoding_and_executable(notebook, metadata, ext):
      
      lines = []
      comment = _SCRIPT_EXTENSIONS.get(ext, {}).get('comment')
      jupytext_metadata = metadata.get('jupytext', {})
  
      if ext not in ['.Rmd', '.md'] and 'executable' in jupytext_metadata:
          lines.append(comment + '!' + jupytext_metadata.pop('executable'))
  
      if 'encoding' in jupytext_metadata:
          lines.append(jupytext_metadata.pop('encoding'))
      elif ext not in ['.Rmd', '.md']:
          for cell in notebook.cells:
              try:
                  cell.source.encode('ascii')
              except (UnicodeEncodeError, UnicodeDecodeError):
                  lines.append(comment + _UTF8_HEADER)
                  break
  
      return lines
docs: Return encoding and executable lines for a notebook, if applicable