code: def cmd_generate(args):
      
      check_output_format(args.output, args.count)
  
      markov = load(MarkovImage, args.state, args)
  
      if args.size is None:
          if markov.scanner.resize is None:
              print('Unknown output image size', file=stderr)
              exit(1)
          width, height = markov.scanner.resize
      else:
          width, height = args.size
  
      if args.level is None:
          scale = markov.scanner.min_size
      else:
          scale = reduce(
              lambda x, y: x * y,
              islice(markov.scanner.level_scale, 0, args.level - 1),
              1
          )
  
      width, height = width // scale, height // scale
  
      markov.scanner.traversal[0].show_progress = args.progress
  
      for fname in outfiles(markov, args.output, args.count, args.progress):
          img = markov(
              width, height,
              state_size=args.state_size,
              levels=args.level
          )
          save_image(img, fname)
docs: Generate images.
  
      Parameters
      ----------
      args : `argparse.Namespace`
          Command arguments.