def instance_create(self, ltype, region, image=None,<EOL>authorized_keys=None, **kwargs):
ret_pass = None<EOL>if image and not '<STR_LIT>' in kwargs:<EOL><INDENT>ret_pass = Instance.generate_root_password()<EOL>kwargs['<STR_LIT>'] = ret_pass<EOL><DEDENT>authorized_keys = load_and_validate_keys(authorized_keys)<EOL>if "<STR_LIT>" in kwargs:<EOL><INDENT>kwargs["<STR_LIT>"] = (kwargs["<STR_LIT>"].id if issubclass(type(kwargs["<STR_LIT>"]), Base)<EOL>else kwargs["<STR_LIT>"])<EOL>del kwargs["<STR_LIT>"]<EOL><DEDENT>if "<STR_LIT>" in kwargs:<EOL><INDENT>kwargs["<STR_LIT>"] = (kwargs["<STR_LIT>"].id if issubclass(type(kwargs["<STR_LIT>"]), Base)<EOL>else kwargs["<STR_LIT>"])<EOL>del kwargs["<STR_LIT>"]<EOL><DEDENT>params = {<EOL>'<STR_LIT:type>': ltype.id if issubclass(type(ltype), Base) else ltype,<EOL>'<STR_LIT>': region.id if issubclass(type(region), Base) else region,<EOL>'<STR_LIT:image>': (image.id if issubclass(type(image), Base) else image) if image else None,<EOL>'<STR_LIT>': authorized_keys,<EOL>}<EOL>params.update(kwargs)<EOL>result = self.client.post('<STR_LIT>', data=params)<EOL>if not '<STR_LIT:id>' in result:<EOL><INDENT>raise UnexpectedResponseError('<STR_LIT>', json=result)<EOL><DEDENT>l = Instance(self.client, result['<STR_LIT:id>'], result)<EOL>if not ret_pass:<EOL><INDENT>return l<EOL><DEDENT>return l, ret_pass<EOL>
Creates a new Linode Instance. This function has several modes of operation:

**Create an Instance from an Image**

To create an Instance from an :any:`Image`, call `instance_create` with
a :any:`Type`, a :any:`Region`, and an :any:`Image`.  All three of
these fields may be provided as either the ID or the appropriate object.
In this mode, a root password will be generated and returned with the
new Instance object.  For example::

   new_linode, password = client.linode.instance_create(
       "g6-standard-2",
       "us-east",
       image="linode/debian9")

   ltype = client.linode.types().first()
   region = client.regions().first()
   image = client.images().first()

   another_linode, password = client.linode.instance_create(
       ltype,
       region,
       image=image)

**Create an Instance from StackScript**

When creating an Instance from a :any:`StackScript`, an :any:`Image` that
the StackScript support must be provided..  You must also provide any
required StackScript data for the script's User Defined Fields..  For
example, if deploying `StackScript 10079`_ (which deploys a new Instance
with a user created from keys on `github`_::

   stackscript = StackScript(client, 10079)

   new_linode, password = client.linode.instance_create(
      "g6-standard-2",
      "us-east",
      image="linode/debian9",
      stackscript=stackscript,
      stackscript_data={"gh_username": "example"})

In the above example, "gh_username" is the name of a User Defined Field
in the chosen StackScript.  For more information on StackScripts, see
the `StackScript guide`_.

.. _`StackScript 10079`: https://www.linode.com/stackscripts/view/10079
.. _`github`: https://github.com
.. _`StackScript guide`: https://www.linode.com/docs/platform/stackscripts/

**Create an Instance from a Backup**

To create a new Instance by restoring a :any:`Backup` to it, provide a
:any:`Type`, a :any:`Region`, and the :any:`Backup` to restore.  You
may provide either IDs or objects for all of these fields::

   existing_linode = Instance(client, 123)
   snapshot = existing_linode.available_backups.snapshot.current

   new_linode = client.linode.instance_create(
       "g6-standard-2",
       "us-east",
       backup=snapshot)

**Create an empty Instance**

If you want to create an empty Instance that you will configure manually,
simply call `instance_create` with a :any:`Type` and a :any:`Region`::

   empty_linode = client.linode.instance_create("g6-standard-2", "us-east")

When created this way, the Instance will not be booted and cannot boot
successfully until disks and configs are created, or it is otherwise
configured.

:param ltype: The Instance Type we are creating
:type ltype: str or Type
:param region: The Region in which we are creating the Instance
:type region: str or Region
:param image: The Image to deploy to this Instance. If this is provided
              and no root_pass is given, a password will be generated
              and returned along with the new Instance.
:type image: str or Image
:param stackscript: The StackScript to deploy to the new Instance.  If
                    provided, "image" is required and must be compatible
                    with the chosen StackScript.
:type stackscript: int or StackScript
:param stackscript_data: Values for the User Defined Fields defined in
                         the chosen StackScript.  Does nothing if
                         StackScript is not provided.
:type stackscript_data: dict
:param backup: The Backup to restore to the new Instance.  May not be
               provided if "image" is given.
:type backup: int of Backup
:param authorized_keys: The ssh public keys to install in the linode's
                        /root/.ssh/authorized_keys file.  Each entry may
                        be a single key, or a path to a file containing
                        the key.
:type authorized_keys: list or str
:param label: The display label for the new Instance
:type label: str
:param group: The display group for the new Instance
:type group: str
:param booted: Whether the new Instance should be booted.  This will
               default to True if the Instance is deployed from an Image
               or Backup.
:type booted: bool

:returns: A new Instance object, or a tuple containing the new Instance and
          the generated password.
:rtype: Instance or tuple(Instance, str)
:raises ApiError: If contacting the API fails
:raises UnexpectedResponseError: If the API resposne is somehow malformed.
                                 This usually indicates that you are using
                                 an outdated library.