code: def _create_tmpfile(cls, status):
      
  
      # We can't put the tmpfile in the same directory as the output. There are
      # rare circumstances when we leave trash behind and we don't want this trash
      # to be loaded into bigquery and/or used for restore.
      #
      # We used mapreduce id, shard number and attempt and 128 random bits to make
      # collisions virtually impossible.
      tmpl = string.Template(cls._TMPFILE_PATTERN)
      filename = tmpl.substitute(
          id=status.mapreduce_id, shard=status.shard,
          random=random.getrandbits(cls._RAND_BITS))
  
      return cls._open_file(status.writer_spec, filename, use_tmp_bucket=True)
docs: Creates a new random-named tmpfile.