title: Generate a pydantic model from pydantic object
body: <p>is it possible to create a pydantic model form an instance of a pydantic model, so that the values are maintained ? Something like this:</p>
  <pre><code>from pydantic import create_model,BaseModel,Field
  from typing import Optional
  
  class ExampleModel(BaseModel):
      some_text: str
      optional_number: Optional[float]
  
  instance=ExampleModel(some_text=&quot;foo&quot;)
  
  dynamic_Model=create_model(&quot;Parameters&quot;,__config__=instance.Config)
  dyn_instance=dynamic_Model()
  
  print(instance)
  print(dyn_instance) #this has no attributes so it's an empty line
  print(&quot;Is it equal ? &quot;+ str(dyn_instance == instance)) #can this be true?
  </code></pre>
  <p>If you wonder about the use case. I want to build an web-app with <a href="https://streamlit.io/" rel="nofollow noreferrer">Streamlit</a> and <a href="https://github.com/LukasMasuch/streamlit-pydantic" rel="nofollow noreferrer">Streamlit-pydantic</a>. The later reders an UI-inputmask from a pydantic model like this:</p>
  <pre><code>instance_of_pydantic_model=sp.pydantic_form(model=pydanticModel, key='some key')
  </code></pre>
  <p><a href="https://share.streamlit.io/lukasmasuch/streamlit-pydantic/main/playground/playground_app.py" rel="nofollow noreferrer">See it in action</a></p>
  <p>This leads in a multi-page application to the problem, that the Input_mask will not display any of the user input after switch to another page an back.</p>